Hi,
Can someone please help?
I have written the following uload file script: -
<?php
//define a constant for the maximum upload size
define ('MAX_FILE_SIZE', 10000000);
if (array_key_exists('Upload', $_POST))
{
//define constant for upload folder
define('UPLOAD_DIR', "$foldername");
//replace any spaces in original filename with underscores
//at the same time, assign to a simpler variable
$file = str_replace(' ', '_', $_FILES['upload']['name']);
//convert the maximum size to MB
$max = number_format(MAX_FILE_SIZE/1048576, 1).'MB';
//begin by assuming file is unacceptable
$sizeOK = false;
//check that the file is in the permitted size
if ($_FILES['upload']['size'] > 0 && $_FILES['upload']['size'] <= MAX_FILE_SIZE)
{
$sizeOK = true;
}
if ($sizeOK)
{
switch($_FILES['upload']['error'])
{
case 0:
//move the file to the upload folder and rename it
$success = move_uploaded_file($_FILES['upload']['tmp_name'], UPLOAD_DIR.$file);
if ($success)
{
$result = "$file uploaded successfully";
}
else
{
$result = "Error uploading $file. Please try again.";
}
break;
case 3:
$result = "Error uploading $file. Please try again.";
default:
$result = "System error uploading file. Contact support.";
}
}
elseif ($_FILES['upload']['error'] == 4)
{
$result = 'No file selected';
}
else
{
$result = "$file cannot be uploaded. Maximum size: $max.";
}
}
?>[/B]
Now, when I run the script & try to upload a file which is under the maximum file size limit I get an error such as: -
'30_Feature_Guide.pdf cannot be uploaded. Maximum size: 9.5MB.'
The file is 5,688KB in size.
Any idea's?