Php file upload problems

Source: Internet
Author: User
Php file upload problems such as Question & nbsp; mainly want to solve the problem of uploading duplicate file names & nbsp; add the upload time before the file name to solve & nbsp; but reported waring & nbsp; problem code if & nbsp; (file_exists (upload_jpg.1. & nbsp ;. & nbsp; $ _ FILES [file] [name]) & nbsp; & nbsp php file upload problems
For example, if you want to solve the problem of uploading duplicate file names, add the upload time before using the file name to solve the problem but report the waring problem code.
If (file_exists ("upload_jpg/". "1". "/". $ _ FILES ["file"] ["name"])
{
Date_default_timezone_set ("Asia/Hong_Kong ");
$ Date_time = date ("H: I: s ");
$ Filename = $ date_time. ". jpg ";
Echo "upload_jpg/". $ id. "/". $ filename;
Echo "duplicate files exist in the directory. the file name has been changed to". $ filename;
Move_uploaded_file ($ _ FILES ["file"] ["tmp_name"], "upload_jpg/". $ id. "/". $ filename );
}
Else
{
Move_uploaded_file ($ _ FILES ["file"] ["tmp_name"], "upload_jpg/". $ id. "/". $ filename );
}


Warning: move_uploaded_file (upload_jpg/1/15:49:21. jpg): failed to open stream: Invalid argument in)

Warning: move_uploaded_file (): Unable to move 'C: \ Windows \ Temp \ php98A. tmp 'to 'upload _ jpg/1/15:49:21. jpg 'in (the error location is in the if true bracket move_uploaded_file () line)


Before (if the third row of true parentheses) $ filename = $ date_time. ". jpg "; mistakenly written to $ filename = date_time. ". jpg "The result is successfully stored. I think it is a problem of date_time, but I have pasted the date_time value to rename the file.
Please advise

PHP Upload

Share:


------ Solution --------------------
At least the colon (:) in the window cannot appear in the file name.

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.