File Upload not working

Hey everyone,
I wrote a file upload, very simple one, but somehow its not working… I think the problem is that the file is not getting received by the PHP script.
Here’s the form:

<form enctype="multipart/form-data" id = "documentupld" action = "documentadd.php" method = "POST">
           <input type="hidden" name="MAX_FILE_SIZE" value="128000000" />

           <p>
            <label for = "file">Select file for upload</label>
            <input name = "document" type = "file" >
           </p>
           
           <p>
            <label for = "submit"></label>
            <input type = "submit" name = "submit" value = "Submit!"/>
           </p>
           
          </form>

Here’s the PHP script:

[php]

<?php $target_path = "../docs/"; $target_parth = $target_path.basename($_FILES['document']['name']); print $target_path."
"; if(move_uploaded_file($_FILES['document']['tmp_name'], $target_path)) { echo "The file ".basename( $_FILES['document']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } ?>

[/php]

When the $target_path gets printed, it just comes as “…/docs/”, and not the file name.

Thanks for your help
Ramanakumar

Hello again…
sorry realised my mistake, my variable was $target_parth instead of path… :smiley:

I decided to change it to sites/ro.ma/files so that it’s in its own place.

Then I updated the files table in database so that all the old files respect the new paths.

Then I cleared cache.

So, everything ok until that, but when I try to upload new files or to access my content type fields using imagecache it doesn’t work. Files are evidently not created in the right place. The imagecache directory (sites/ro.ma/files/imagecache) is also empty and without subdirectories.

Sponsor our Newsletter | Privacy Policy | Terms of Service