我正在尝试通过创建一个小的上传表单将PDF上传到菜单目录并为其指定特定名称以便覆盖以前的版本,从而轻松地在线为一些同事更新菜单(两个PDF)。
这是我到目前为止所拥有的......
形式:
<section>
<form action="menu_uploader.php" method="post" id="menu_upload" name="menu_upload" enctype="multipart/form-data" >
<p><label for="wine_list_menu_upload">Wine List -> </label> <input type="file" name="wine_list_menu_upload" id="wine_list_menu_upload"></p>
<p><label for="food_flight_menu_upload">Food & Flights -> </label> <input type="file" name="food_flight_menu_upload" id="food_flight_menu_upload"></p>
<p><input type="submit" name="submit" value="Upload" id="submit"></p>
</form>
</section>
PHP
<?php
if( ($_FILES["wine_list_menu_upload"]["type"] == "application/pdf") &&
($_FILES["food_flight_menu_upload"]["type"] == "application/pdf") &&
($_FILES["wine_list_menu_upload"]["size"] < 1048576*5) &&
($_FILES["food_flight_menu_upload"]["size"] < 1048576*5))
{
if($_FILES["wine_list_menu_upload"]["error"] > 0 || $_FILES["food_flight_menu_upload"]["error"] > 0)
{echo "Error Code: " . $_FILES["wine_list_menu_upload"]["error"] xor $_FILES["food_flight_menu_upload"]["error"] . "<br>";}
else
{move_uploaded_file($_FILES["wine_list_menu_upload"]["tmp_name"], "tasting-bar/menus/test/SEWC-Wine_Menu.pdf");
move_uploaded_file($_FILES["food_flight_menu_upload"]["tmp_name"], "tasting-bar/menus/test/SEWC-Food_Flight_Menu.pdf");
echo "Menus uploaded successfully!"; }
}
else
{
echo "Invalid file type. Must be a PDF and under 5MB. Sorry!<br/>";
echo "File Type - " . $_FILES["wine_list_menu_upload"]["type"] . "<br/>";
echo "File Name - " . $_FILES["wine_list_menu_upload"]["name"];
}
?>
我需要将“wine_list_menu_upload”重命名为“SEWC-Wine_Menu.pdf”并进入“品尝栏/菜单/”, “food_flight_menu_upload”重命名为“SEWC-Food_Flight_Menu.pdf”并改为“品尝酒吧/菜单/”
我做错了什么?
答案 0 :(得分:0)
尝试在move_uploaded_file
chmod('tasting-bar/', 0777);
chmod('tasting-bar/menus', 0777);
chmod('tasting-bar/menus/test/', 0777);
如果它的权限问题,它应该用这个解决