[英]copy(): Filename cannot be empty - for some files
when I am trying to upload some videos to the server I get this error: 当我尝试将一些视频上传到服务器时,出现此错误:
copy(): Filename cannot be empty
copy():文件名不能为空
I only get this for some videos and not for all of them, but all of them are mp4. 我只为某些视频而不是所有视频获取此信息,但所有视频均为mp4。
the code is: 代码是:
$video_name = uniqid().'.'.$extension;
$newname="videos/".$video_name;
$copied = copy($_FILES['video_src']['tmp_name'], $newname);
And both post_max_size
and upload_max_filesize
are setto 50Mb while the videos are smaller than 10Mb. 而且两者
post_max_size
和upload_max_filesize
是50MB的setto而视频是小于10MB。
Any idea? 任何想法?
Try the move_uploaded_file() function. 尝试使用move_uploaded_file()函数。 Also, you should probably change
$newname
: 另外,您可能应该更改
$newname
:
$video_name = uniqid().'.'.$extension;
$newname="./videos/".$video_name;
$orig = isset($_FILES['video_src']) && isset($_FILES['video_src']['tmp_name']) ? $_FILES['video_src']['tmp_name'] : '';
if (empty($orig)) {
echo "Uploaded file doesn't exist.";
}
$copied = move_uploaded_file($orig, $newname);
// Optional
if ($copied) {
echo "File moved.";
}
else {
echo "File not moved.";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.