我试图在上传torrent文件时显示错误,但是我不成功。这里的问题是代码:加载文件时显示错误
if (empty($_POST) === false) {
$required_fields = array('torr', 'name', 'genre', 'cat', 'descr');
foreach($_POST as $key=>$value){
if (empty($value) && in_array($key, $required_fields) === true){
$errors[] = "<font color='#eeeeee'> Campurile marcate cu * sunt obligatorii.</font><br>";
break 1;
}
}
}
等
这里是我上传的代码:
if (isset($_FILES['torr']) === true){
$allowed = array('torrent');
$file_name = $_FILES['torr']['name'];
$file_extn = strtolower(end(explode('.' ,$file_name)));
$file_temp = $_FILES['torr']['tmp_name'];
if(in_array($file_extn, $allowed) === false){
$errors[] = "nu`i fisier torent";
}else{
$file_path = 'media/torr/' . $name . '-www.LegacyRo.info-' .substr(md5(time()), 0, 10) . '.' . $file_extn;
move_uploaded_file($file_temp, $file_path);
}
和,而不是显示一个错误,当我尝试上传了另一种我得到这个:
注意:未定义的变量:在x/y/z中的file_path
我知道查询跳出file_path,因为扩展名不被允许,但我希望它被显示为错误。
任何想法?
这里是为了更好地理解糊箱: http://pastebin.com/z3vkRVUx
看起来像我不得不做的是移动中的错误区域内的延伸检查。现在都好。感谢您的回复
在未来,请尽量不要将一堆代码堆成一行。 – castis
我对1线感到抱歉,但我无法用其他任何方式做到。正如你所看到的,我使用第二个块进行管理,但不是第一个 –