View previous topic :: View next topic |
Author |
Message |
goodmangroup -
Joined: 17 Aug 2011 Posts: 1
|
Posted: Wed Aug 17, 2011 7:37 am Post subject: Uploader Script Error |
|
|
Hi,
Hi, i am receving this error "Sorry, there was a problem uploading your file." when trying to upload any document type to our webserver.
Client Website: http://www.lisadaviesandassociates.com.au/test/file_upload.html
HTML CODE:
<html>
<head>
<title>PHP File Upload Example</title>
</head>
<form method="POST" enctype="multipart/form-data" action="./upload.php">
<label for="file">Select a file:</label> <input type="file" name="userfile" value=""><br />
<button type="submit">Upload File</button>
</form>
</body>
</html>
PHP CODE:
<?php
$target = "./test/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) ;
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
}
else {
echo "Sorry, there was a problem uploading your file.";
}
?>
Any help would be much appreciated.
Thanks _________________ Rory Carter
Goodman Group Pty Ltd |
|
Back to top |
|
|
admin Site Admin
Joined: 03 Mar 2002 Posts: 1295
|
Posted: Fri Aug 19, 2011 3:30 pm Post subject: Re: Uploader Script Error |
|
|
goodmangroup,
Your HTML file should also use uploaded as the variable name instead of userfile as in :
Code: | <input type="file" name="uploaded" value=""> |
From a quick look to the code there is also an error :
Code: |
echo "The file ". basename( $_FILES['uploaded']['name']). " has been uploaded"; |
should be:
Code: |
echo "The file ". basename( $_FILES['uploaded']['name']). " has been uploaded"; |
Your script requires that you create a subdirectory called "test" inside the directory where that .php script is. This is the main reason for the failure of that script that we can spot.
But the best is to let the script report the error code for the failure by changing the line :
Code: | echo "Sorry, there was a problem uploading your file."; |
into :
Code: | echo "Sorry, there was a problem uploading your file - error code = ." . $_FILES['uploaded']['error'] ; |
The reported numeric value should be checked in <http://www.php.net/manual/en/features.file-upload.errors.php> where the error values are explained. _________________ Follow @abyssws on Twitter
Subscribe to our newsletter
_________________
Forum Administrator
Aprelium - https://aprelium.com |
|
Back to top |
|
|
|