我想要做的是當管理員試圖創建一個新的產品上傳到服務器的圖像,因爲它的名稱是產品id.jpg。我搜索谷歌沒有結果。代碼似乎是正確的。有人能幫助我嗎?我使用燈作爲本地測試服務器。上傳文件映像到服務器失敗
<?php
// Parse the form data and add inventory item to the system
if (isset($_POST['product_name'])) {
$product_name = mysql_real_escape_string($_POST['product_name']);
$price = mysql_real_escape_string($_POST['price']);
$details = mysql_real_escape_string($_POST['details']);
$category = mysql_real_escape_string($_POST['category_choice']);
$condition= mysql_real_escape_string($_POST['condition']);
$supplier_choice= mysql_real_escape_string($_POST['supplier_choice']);
$handling_time= mysql_real_escape_string($_POST['handling_time']);
$weight= mysql_real_escape_string($_POST['weight']);
$information_box= $_POST['information'];
$pid = mysql_insert_id();
// Place image in the folder
$newname = "$pid.jpg";
move_uploaded_file($_FILES['my_photo']['tmp_name'], "../inventory_images/$newname");
header("location: products.php");
exit();
}
?>
<form action="add_product.php" enctype="multipart/form-data" name="my_Form" id="my_Form" method="post">
<tr>
<td>Φωτογραφία</td>
<td>
<label>
<input type="file" name="my_photo" id="my_photo"/>
</label>
</td>
</tr>
<tr>
<td> </td>
<td>
<label>
<input type="submit" name="button" id="button" value="Αποθήκευση" />
</label>
</td>
</tr>
</table>
</form>
你給你的腳本寫權限到你的圖像將被移動的文件夾? – ppp
如果有人上傳一個php文件,當你非常小心地使用mysql_real_escape_string時,你不關心嗎? var_dump($ _ FILES ['my_photo'] ['error'])'說什麼? –
我怎麼能在我的PHP權限給文件夾? – JimmyV