An error occurred while uploading a file.

Source: Internet
Author: User
An error occurred while uploading a file.
 Upload.
 
  
Upload your file
  


This is used to call the following php on the front-end page.
 ";echo "clicktherereturn!";}else {$filepath="upload/";$name=$filepath.$_FILES["upload"]["name"];while (file_exists($name)){$temp=explode(".", $name);$name=$temp[0]."0".".".$temp[1];}if(move_uploaded_file($_FILES["upfile"]["tmp_name"], $name)){if ($_POST["owner"]){$owner=$_POST["owner"];}else {$owner="NULL";}if ($_POST["describe"]){$describe=$_POST["describe"];}else{$describe="NONE";}$time=date("y-m-d H:m:s");$content=$_FILES["upload"]["name"]."||".$owner."||".$describe."||".$time."\n";file_put_contents("record.dat", $content.FILE_APPEND);echo "name:".$_FILES["upfile"]["name"];echo "

";echo "is upload successfull.

";echo "clicktherereturn!";}else {echo "upload error!

";echo "fail!

";echo "clicktherecheck!";}}?>


The problem is that after the upload, the system prompts that the file is successfully uploaded, but the file name in the upload folder is a multiple of 0 and there is no file format. what is the problem?


The following errors are prompted ..
Notice: Undefined index: upfile in D: \ phpnow \ htdocs \ B \ up_back.php on line 2

Notice: Undefined index: upload in D: \ phpnow \ htdocs \ B \ up_back.php on line 10

Notice: Undefined offset: 1 in D: \ phpnow \ htdocs \ B \ up_back.php on line 14

Notice: Undefined index: upload in D: \ phpnow \ htdocs \ B \ up_back.php on line 35
Name: 10.jpg


Reply to discussion (solution)

This line $ name = $ filepath. $ _ FILES ["upload"] ["name"];
Name = "file" for the first file upload, no "upload.

Move_uploaded_file ($ _ FILES ["upfile"] ["tmp_name"], $ name) is not followed by a path

Move_uploaded_file ($ _ FILES ["upfile"] ["tmp_name"], $ name) is not followed by a path

His $ name = $ filepath. $ _ FILES ["upfile"] ["name "];

1.
If (! $ _ POST ["upfile"] & $ _ FILES ["upfile"] ["name"] = "")
==>
If ($ _ FILES ["upfile"] ["name"] = "") // you can determine whether to select a file.

2.
$ Name = $ filepath. $ _ FILES ["upload"] ["name"];
="
$ Name = $ filepath. $ _ FILES ["upfile"] ["name"];

3. if your file exists. Is the while loop an endless loop? you can change it:
If (file_exists ($ name ))
{
$ Temp = explode (".", $ name );
$ Name = $ temp [0]. "0". $ temp [1];
}
4. $ content = $ _ FILES ["upfile"] ["name"]. "| ". $ owner. "| ". $ describe. "| ". $ time. "\ n ";

1.
If (! $ _ POST ["upfile"] & $ _ FILES ["upfile"] ["name"] = "")
==>
If ($ _ FILES ["upfile"] ["name"] = "") // you can determine whether to select a file.

2.
$ Name = $ filepath. $ _ FILES ["upload"] ["name"];
="
$ Name = $ filepath. $ _......
Thanks for your help. after the modification, the module function is indeed completed... thank you very much.

This line $ name = $ filepath. $ _ FILES ["upload"] ["name"];
Name = "file" for the first file upload, no "upload.
Well, there is something wrong with it. thank you.

1.
If (! $ _ POST ["upfile"] & $ _ FILES ["upfile"] ["name"] = "")
==>
If ($ _ FILES ["upfile"] ["name"] = "") // you can determine whether to select a file.

2.
$ Name = $ filepath. $ _ FILES ["upload"] ["name"];
="
$ Name = ......
Great Gods are taught

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.