Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

another error

Contributor ,
Feb 08, 2007 Feb 08, 2007
hey again.
I am now learning how to handle file uploads , i created the php code :

http://therainbowpride.com/myphptests/uploads/upload_file.php

THIS IS THE CODE:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Upload a file</title>
</head>
<body>
<?php // Script 11.4 - upload_file.php
// This script displays and handles an HTML form.
// This script takes a file upload and stores it on the server.


// Address error handling.
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);

if (isset ($_POST['submit'])) { // Handle form.

// Try to move the uploaded file.
if (move_uploaded_file ($_FILES['thefile']['tmp_name'], "../uploads/{$_FILES['thefile']['name']}")) {

print '<p>Your file could not be uploaded.</p>';

} else { //Problem!

print '<p>Your file could not be uploaded because: <b>';

// Print a message based upon the error.
switch ($_FILES['thefile']['error']) {
case 1:
print 'The file exceeds the upload_max_filesize setting in php.ini';
break;
case 2:
print 'The file exceeds the MAX_FILE_SIZE setting in the HTML form';
break;
case 3:
print 'The file was only partially uploaded';
break;
case 4:
print 'No file was uploaded';
break;
}
print '</b>.</p>';
}

} // End of SUBMIT IF.

// Leave PHP and display the form.
?>

<form action="upload_file.php"
enctype="multipart/form-data" method="post">
<p>Upload a file using this form: <br /><br />
<input type="hidden" name="MAX_FILE_SIZE" value="300000" />
<input type="file" name="thefile" /><br /><br />
<input type="submit" name="submit" value="Upload This File" />
</p>
</form>
</body>
</html>


I was getting error : The file exceeds the MAX_FILE_SIZE. so i went and changed it.
But now all i get when i browse and submit a file is this error :

Your file could not be uploaded

I created the "uploads" folder in my web sever and uploaded the "upload_file.php to it.

What can i do to fix this. Even tho it says could not be uploaded, it still shows on the folder "uploads"

thanks guys.
TOPICS
Server side applications
362
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 09, 2007 Feb 09, 2007
LuisDesigns wrote:
> // Try to move the uploaded file.
> if (move_uploaded_file ($_FILES['thefile']['tmp_name'],
> "../uploads/{$_FILES['thefile']['name']}")) {
>
> print '<p>Your file could not be uploaded.</p>';
>
> } else { //Problem!

Your error message is wrong. If the conditional statement
move_uploaded_file(etc) is true, the file has been uploaded successfully.

> What can i do to fix this. Even tho it says could not be uploaded, it still
> shows on the folder "uploads"

The message is wrong, not the code.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 09, 2007 Feb 09, 2007
what do you mean ? Can't i just type any message i want ?????
what do i need to change?
thanks again
And is it normal that even tho it says not uploaded, it does move the file to the directory ?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 09, 2007 Feb 09, 2007
it says for me to upload the upload_file.php to my web server in the directory bellow "uploads folder".

I uploaded into the uploads folder. And i get the message error.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 09, 2007 Feb 09, 2007
OMG.
I AM SO SORRY .
Please everybody, take no notice on this Topic, i saw what u mean, i just can't believe that i look over and over and couldn't find where the mistake was. I guess i stayed up too many hour looking at codes, lol.

Thank you so much everyone, Thank you David Powers, my bad, i should've looked a lil more.

Thanks again
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 10, 2007 Feb 10, 2007
LuisDesigns wrote:
> OMG.
> I AM SO SORRY .
> Please everybody, take no notice on this Topic, i saw what u mean, i just
> can't believe that i look over and over and couldn't find where the mistake
> was. I guess i stayed up too many hour looking at codes, lol.

Don't worry. It happens to us all. ;-)

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 10, 2007 Feb 10, 2007
LATEST
i guess all this codings gets to our brains.
lmao
thanks again
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines