0

Using an example from http://www.tizag.com/phpT/fileupload.php. I am using PHP 5.3 at godaddy

I get this error using the above example "No input file specified."

I get the error in the sequence when I hit the "upload File" button.

<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>

<?php
$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!";
}
?>

Both upload.php and upload-file.html are in the same directory.

and i have the "uploads" directory in there

5
  • 2
    where exactly do you get the error? Commented Aug 11, 2011 at 15:15
  • I get the error, in the sequence, when I hit the "upload File" button. Commented Aug 11, 2011 at 15:16
  • Is it a browser error or a script error? doeas the page refresh? does it mention a line in your code? Commented Aug 11, 2011 at 15:19
  • I get the same error in "Safari", "Firefox". On the error screen, if i hit refresh, it shows the same error. no code line is mentioned. Commented Aug 11, 2011 at 15:23
  • Warning: move_uploaded_file(uploads/train.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in D:\Hosting\8234072\html\upload.php on line 6 NOW I GET: Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'D:\Temp\php\php4BA8.tmp' to 'uploads/train.jpg' in D:\Hosting\8234072\html\upload.php on line 6 There was an error uploading the file, please try again! Commented Aug 11, 2011 at 15:30

1 Answer 1

0

Just quickly Google the message and it looks like you might be getting the message from PHP as an Apache CGI because 'uploader.php' doesn't exist or is not in the same directory as the one with the HTML form - what are your files called and what are their paths on the server?

See the 'action' attribute of the <form> element of your HTML file.

Sign up to request clarification or add additional context in comments.

2 Comments

if I just do... upload.php, i get "There was an error uploading the file, please try again!" which is a line from the code which is in the same directory.
Try changing echo "There was an error uploading the file, please try again!"; to echo "There was an error uploading the file, please try again! (".$_FILES['uploadedfile']['error'].")"; to display the error code, then look it up in the PHP manual and report back :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.