Php move_upload_file()函数不上载到我的文件夹
我正在制作一个带有CMS的电子商务网站,在这里我可以编辑、添加产品等,当我添加产品并从我的计算机中选择图像时,它不会上传到我为图像“上传”而制作的文件夹中 有人知道这个问题的解决方案吗,可能在我的代码中,但我似乎无法理解 如果我手动将图像添加到文件夹上载,并在添加产品时选择图像,则图像会显示 这是我的密码:Php move_upload_file()函数不上载到我的文件夹,php,mysqli,Php,Mysqli,我正在制作一个带有CMS的电子商务网站,在这里我可以编辑、添加产品等,当我添加产品并从我的计算机中选择图像时,它不会上传到我为图像“上传”而制作的文件夹中 有人知道这个问题的解决方案吗,可能在我的代码中,但我似乎无法理解 如果我手动将图像添加到文件夹上载,并在添加产品时选择图像,则图像会显示 这是我的密码: function add_product() { if(isset($_POST['publish'])) { $product_title = escape
function add_product() {
if(isset($_POST['publish'])) {
$product_title = escape_string($_POST['product_title']);
$product_category_id = escape_string($_POST['product_category_id']);
$product_price = escape_string($_POST['product_price']);
$product_description = escape_string($_POST['product_description']);
$short_desc = escape_string($_POST['short_desc']);
$product_quantity = escape_string($_POST['product_quantity']);
$product_image = escape_string($_FILES['file']['name']);
$image_temp_location = escape_string($_FILES['file']['tmp_name']);
move_uploaded_file($image_temp_location, UPLOAD_DIRECTORY . DS . $product_image);
$query = query("INSERT INTO products(product_title, product_category_id, product_price, product_description, short_desc, product_quantity, product_image) VALUES('{$product_title}', '{$product_category_id}', '{$product_price}', '{$product_description}', '{$short_desc}', '{$product_quantity}', '{$product_image}')");
$last_id = last_id();
confirm($query);
set_message("New Product with id {$last_id} was Added");
redirect("index.php?products");
}
}
UPLOAD_目录是我在一个名为config.php的文件中配置的路径,如下所示:
defined("UPLOAD_DIRECTORY") ? null : define("UPLOAD_DIRECTORY", __DIR__ . DS . "uploads");
显示了什么?抱歉,我仍然不知道该怎么做…将此添加到php文件
错误报告(E_ALL)的顶部;ini设置(“显示错误”,1)代码>无,没有错误,仍然是相同的问题。您不应该使用此值转义\u字符串($\u FILES['file']['tmp\u name'])
在移动上传的文件()
使用原始的$\u文件['file']['tmp\u name']
显示什么?抱歉,我仍然不知道该怎么做…将此添加到php文件错误报告(E\u ALL)的顶部;ini设置(“显示错误”,1)代码>无,没有错误,仍然是相同的问题。您不应该使用此值转义\u字符串($\u FILES['file']['tmp\u name'])
在移动上传的文件()
中使用原始的$\u文件['file']['tmp\u name']