Zip 未上传:- (
由于某种原因,当尝试上传 zip 文件时,此函数总是返回 false。目录的权限都设置为0777。我很困惑可能出了什么问题。
function uploadProof ( $file, $email )
{
// Check or create for existing directory
if ( !is_dir('client_files/'.$email))
{
mkdir('client_files/'.$email);
if ( !is_dir('client_files/'.$email.'/proof/'))
{
mkdir('client_files/'.$email.'/proof/');
}
}
// Target path
$target_path = 'client_files/'.$email.'/proof/';
// File information
$filename = date('Y_M_D').$email.'.zip';
$tmp_name = $file['tmp_name'];
$filesize = $file['size'];
// Blacklist and Max file info
$max_allowed = (1024 * 1024) * 99; // 99 MB
$blacklist = array(
'.pl', '.php', '.phtml', '.php3', '.php4', '.php5'
);
// Check filename
foreach ( $blacklist as $nope)
{
if ( preg_match("/$nope\$/i", $filename))
{
die("As previously stated, we do not allow php files of any type\n
to be uploaded to our server.\n\n");
}
}
// Check filesize
if ( $filesize > $max_allowed)
{
die("File is too big, file needs to be less than <em>20MB</em> in size.");
}
else
{
$target = $target_path.$filename;
if (move_uploaded_file($tmp_name, $target))
{
return true;
}
else
{
return false;
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在继续执行一组可能完全无用的操作之前,您确实需要检查上传是否确实成功:
错误代码定义为 此处。
You do need to check if the upload actually succeeded, before going on to do what might be a totally useless set of operations:
The error codes are defined here.