Home >Backend Development >PHP Tutorial > php上传文件有关问题

php上传文件有关问题

WBOY
WBOYOriginal
2016-06-13 12:43:25872browse

php上传文件问题
如题 主要想解决上传重复文件名文件的问题 向用文件名前加上传时间来解决 但是报waring 问题代码
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 "目录内存在重复文件,已将文件名改为".$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 (报错位置在if真括号的move_uploaded_file()行)

Warning: move_uploaded_file(): Unable to move 'C:\Windows\Temp\php98A.tmp' to 'upload_jpg/1/15:49:21.jpg' in(报错位置在if真括号的move_uploaded_file()行)


之前(if真括号第三行)$filename=$date_time.".jpg"; 错写成了 $filename=date_time.".jpg" 结果存储成功了,我觉得是这个date_time的问题 但是我粘了date_time的值去重命名文件都是成功的
求指点

PHP 上传
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn