Page 1 of 1

Another Upload Problem

Posted: Wed Oct 03, 2007 10:55 am
by CCloudyVision
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hello,
I have a very simple script and am not interested in security. That being said, I cannot get it to work and I was wondering if you good people could help me find out why. I am an amateur as I am sure you all can tell so please be gentle 

Form.php
[syntax="html"]
<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
Uploader.php[/syntax]

Code: Select all

<html>
<head>
        
 <title>Untitled</title>

</head>
<body>

<?

$target_path = "uploads/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

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


?>
</body>
</html>
I copied this verbatim from one of the tutorials so I am not trying to claim this as my own but I cannot get it to work. The only message I get after trying to upload is the "There was an error..." message. Any help is appreciated. Thanks in advance.


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Wed Oct 03, 2007 11:04 am
by feyd
If you add print_r($_FILES) to your code in uploader.php, what happens in the output?

Posted: Thu Oct 04, 2007 12:22 am
by Hemlata
Hello

The same script is working on my end.. Have you set the 'folder Permission' to 777?

Regards,

Upload reply

Posted: Fri Oct 05, 2007 10:49 am
by CCloudyVision
The folder I am trying to upload to is a public folder. It has no protection atthe moment. I did this to simplify the process. I will try the print_r($_FILES) today. Thank you for the advice!

Update

Posted: Sat Oct 06, 2007 8:48 am
by CCloudyVision
First, I want to say thanks for those who have helped me. I have an update. I finally was able to get an error mesage generated.

PHP Warning: File upload error - unable to create a temporary file in Unknown on line 0

What is "unknown" and line 0 mean?

Posted: Sat Oct 06, 2007 9:04 am
by feyd
It happened outside of your script.