我正在尝试使用以下代码在一个提交按钮中上传两个文件:
<label>Logo Image *</label>
<input type="file" name="ufile[]"/>
<label>Banner Image *</label>
<input type="file" name="ufile[]"/>
PHP
$logo = $_FILES['ufile']['name'][0];
$block_img = $_FILES['ufile']['name'][1];
if ($_FILES['ufile']['name']["error"] > 0) {
echo "error<br>";
}
else {
if (file_exists("small-image/" . $_FILES['ufile']['name'][0])){
echo $_FILES['ufile']['name'][1] . "File already exists in server. ";
}
else {
move_uploaded_file($_FILES['ufile']['name'][0], "small-image/" . $_FILES['ufile']['name'][0]);
move_uploaded_file($_FILES['ufile']['name'][1], "small-image/" . $_FILES['ufile']['name'][1]);
}
}
$sql_query = "UPDATE header_img SET logo_img = '$logo', block_img = '$block_img' WHERE banner_id = 1";
我的数据库正在正确更新,但文件未上传。是的,有一个 777 目录调用“小图像”。
任何的想法?谢谢。