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.