通过PHP上传到服务器时,我遇到了一些奇怪的问题。
我得到文件的类型(正常工作,通过echo显示它们)
$file = $_FILES['file'];
$typeFile = end(explode(".", $file['name']));
然后我做了一些比较,让他们上传或不上传,这里是允许的填充类型
if($file['size'] <= 52428800) { //50MB, and my file is about 2,5MB
if($fileType == "nlpack" || $fileType == "nl2pkg" || $fileType == "nlpark") {
$id = add_to_db($file['name']); //Adding to database the name, this will return an id, it works
if($id) {
mkdir("uploads/".$id); //create a folder where to add the file, working fine!
if(move_uploaded_file($file['tmp_name']), ".uploads/".$id."/".$file['name']) {
echo "file uploaded correctly";
}
else {
echo "has been an error"; //it enters here, while the other file types enters in the if()
}
}
else {
echo "Has been an error";
}
} else {
//alert an error
}
}
问题是,“nlpack”文件类型没有上传,它进入if(),因为我用回声检查了它,而其他两个上传没有问题。
我也检查文件大小,但运行正常。
有关正在发生的事情的任何想法?
提前致谢
答案 0 :(得分:1)
确保文件大小不超过php.ini中的设置,否则文件将无法上传。
upload_max_filesize integer
The maximum size of an uploaded file.
When an integer is used, the value is measured in bytes. Shorthand notation, as described in this FAQ, may also be used.
如果muliple:
max_file_uploads integer
The maximum number of files allowed to be uploaded simultaneously. Starting with PHP 5.3.4, upload fields left blank on submission do not count towards this limit.