我已经在服务器上上传了项目,除了少数几件事以外,每件事情都很好。
我无法将服务器上的文件图像上传,请检查错误。
我甚至将权限设置为777。
警告:move_uploaded_file(../ images / failed to upload.jpg):无法打开流:/srv/disk14/2293074/www/cms.mohsinyounas.info/admin/includes/add_posts中没有此类文件或目录第15行的.php
警告:move_uploaded_file():无法在/srv/disk14/2293074/www/cms.mohsinyounas.info/admin/includes中将'/ tmp / phpx2WZ8c'移动到'../ images/fail to upload.jpg'第15行的/add_posts.php
谢谢。
<?php
include "./function.php";
global $con;
if(isset($_POST['create_post'])) {
$post_image = $_FILES['post_image']['name'];
$post_image_temp = $_FILES['post_image']['tmp_name'];
move_uploaded_file("$post_image_temp","../images/$post_image");
$sql = "INSERT INTO posts (post_image) VALUES ('$post_image')";
$result = mysqli_query($con,$sql);
confirm($result);
}
?>
答案 0 :(得分:1)
更改此代码,您必须从move_uploaded_file()
中的变量中删除“”
<?php
include "./function.php";
global $con;
if(isset($_POST['create_post'])) {
$post_image =$_FILES['post_image']['name'];
$post_image_temp =$_FILES['post_image']['tmp_name'];
$path = "../images/".$post_image;
move_uploaded_file($post_image_temp,$path);
$sql = "INSERT INTO posts (post_image)
VALUES ('$post_image')";
$result=mysqli_query($con,$sql);
confirm($result);
}
?>