[英]PHP file upload move_uploaded_file
Php always shows an error when I try to upload the image to the server. 当我尝试将图像上传到服务器时,php总是显示错误。 image: https://ibb.co/r4crqtF
图片: https : //ibb.co/r4crqtF
The image size is 120kb and I think that is not a problem. 图像大小为120kb,我认为这不是问题。
$product_add_cate = $_POST["product_add_category"];
$target_path = "assets/products/".getImagePath($product_add_cate);
$target_file = $target_path.basename($product_add_imge);
if (move_uploaded_file($_FILES["product_photo"]["tmp_name"], $target_file)) {
echo "success";
} else {
echo "error";
}
function getImagePath($img_category) {
$path = "";
if ($img_category == "product_antidekubitni_program") {
$path = "antidekubitni program/";
} else if ($img_category == "product_bolnicki_kreveti_i_oprema") {
$path = "bolnicki kreveti i oprema/";
} else if ($img_category == "product_invalidska_kolica") {
$path = "invalidska kolica/";
} else if ($img_category == "product_stake_stapovi") {
$path = "stake, stapovi i hodalice/";
} else if ($img_category == "product_toaletni_program") {
$path = "toaletni program/";
} else if ($img_category == "product_ortoze_mideri") {
$path = "ortoze mideri steznici/";
}
return $path;
}
Image HTML 图片HTML
<input type="file" name="product_photo" id="fileToUpload" title="Izaberite fotografiju proizvoda" accept="image/*" required>
MB尝试不要在路径中使用空格,例如,“ ortoze mideri steznici”请尝试“ ortoze-mideri-steznici”,等等。
Try using full path for $target_path, ex. 尝试为$ target_path使用完整路径,例如。 "c:\\app_path\\public_path\\"
“ c:\\ app_path \\ public_path \\”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.