Image upload problem

Hi.

I can’t seem to upload images, the filename is entered into the database but the actual image does not upload…

This is the upload code:


    $target_path = "../galleryimages/";
    $target_path = $target_path . basename( $_FILES['file']['name']);

    if(move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) {
        echo "The file ".  basename( $_FILES['file']['name']).
        " has been uploaded";
    } else{
        echo "There was an error uploading the file, please try again!";
    }

My file upload box is like so:


<input type="hidden" name="MAX_FILE_SIZE" value="100000" /><input type="file" name="file" id="file" value=""/>

But i keep getting “There was an error uploading the file, please try again!”…

I tried doing a var_dump of the files, and this is what i got:


array(1) { ["file"]=>  array(5) { ["name"]=>  string(17) "Winter Leaves.jpg" ["type"]=>  string(0) "" ["tmp_name"]=>  string(0) "" ["error"]=>  int(2) ["size"]=>  int(0) } }

Any ideas what the problem might be?

Can someone please help as i can’t figure it out…

Thanks again

The error in the $_FILES arary indicates that the uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form. Use this before the point in your script where the upload occurs:

$filename = 'somefile.txt';
echo $filename . ': ' . filesize($filename) . ' bytes';

Does the number of bytes displayed exceed the value that you have set in:

<input type="hidden" name="MAX_FILE_SIZE" value="100000" /><input type="file" name="file" id="file" value=""/>  

SpacePhoenix you are a star! :smiley:

I’s all working now, the file was to large so i extended the MAX_FILE_SIZE

Thank you so much, i need to get everything perfect, you know what clients are like :lol:

Thanks again