Another Upload Problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
CCloudyVision
Forum Newbie
Posts: 3
Joined: Fri Sep 21, 2007 11:15 am

Another Upload Problem

Post 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]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If you add print_r($_FILES) to your code in uploader.php, what happens in the output?
Hemlata
Forum Commoner
Posts: 35
Joined: Mon Sep 10, 2007 5:40 am
Location: India
Contact:

Post by Hemlata »

Hello

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

Regards,
CCloudyVision
Forum Newbie
Posts: 3
Joined: Fri Sep 21, 2007 11:15 am

Upload reply

Post 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!
CCloudyVision
Forum Newbie
Posts: 3
Joined: Fri Sep 21, 2007 11:15 am

Update

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

It happened outside of your script.
Post Reply