我知道已經有很多類似的問題,我提前為添加到文件中而道歉,但我做研究的時間有點短,我需要快速幫助。我正在嘗試完成一項逾期的作業,并且我的圖片上傳功能在我添加產品時運行良好,但在我更新產品時卻無法正常運行。我不知道為什么。我更新圖像的代碼在這里:require_once 'file-util.php' // Check if the file exists before setting it if (isset($_FILES['imageFile1'])) { // Retrieve the name of the file based on what it was called on the client computer $filename = $codeInput . '.png'; // Make sure the filename exists if (!empty($filename)) { // Store the temporary location of where the file was stored on the server $sourceLocation = $_FILES['imageFile1']['tmp_name']; // Build the path to the images folder and use the same filename as before $targetPath = $image_dir_path . DIRECTORY_SEPARATOR . $filename; // Move file from temp directory to images folder move_uploaded_file($sourceLocation, $targetPath); } }這與我在 insert_product 文件中的代碼完全相同。我的 file_util 在這里:$image_dir = 'images';$image_dir_path = getcwd() . DIRECTORY_SEPARATOR . $image_dir;其他一切都運行良好,但就是這個小東西似乎什么也沒做,所以在我看來,我缺少一些細節才能在 update_product 中工作。我還需要做些什么才能讓它發揮作用,還是我不知道的其他事情?編輯:原來我只是忘記在我的 add_product_form 中設置加密類型。如果其他人有這個愚蠢的問題,請仔細檢查靠近身體頂部的表格:<form action="insert_product.php" method="post" id="add_product_form" enctype="multipart/form-data">
- 2 回答
- 0 關注
- 98 瀏覽
添加回答
舉報
0/150
提交
取消