gpt4 book ai didi

php - move_uploaded_file() 错误

转载 作者:行者123 更新时间:2023-12-01 22:45:05 24 4
gpt4 key购买 nike

我有一个免费托管网站 - 000webhost.com,它允许您上传图片。

但是,当我尝试上传图片时,出现以下错误:

警告:move_uploaded_file(images/SmallSmileyFace.jpg) [function.move-uploaded-file]:无法打开流:第 76 行/home/a6621074/public_html/m/write.php 中的权限被拒绝

警告:move_uploaded_file() [function.move-uploaded-file]:无法在线将“/tmp/phpcmW3mo”移动到/home/a6621074/public_html/m/write.php 中的“images/SmallSmileyFace.jpg” 76

这是代码:

if (!empty($_FILES['fileImage']['name'])) {
// check image type and size
if ((($imagetype == 'image/gif') || ($imagetype == 'image/jpeg') || ($imagetype == 'image/pjpeg') || ($imagetype == 'image/png'))
&& ($imagesize > 0) && ($imagesize <= 32768)) {

if ($_FILES['fileImage']['error'] == 0) {
//move file
$target = 'images/' . $image;
if (move_uploaded_file($_FILES['fileImage']['tmp_name'], $target)) {
$query = "INSERT INTO reviews (post_date, food_name, location, cafeteria, review, image, rating, user_id)
VALUES (NOW(), '$foodname', '$location', '$cafeteria', '$review', '$image', $rate, $id)";

mysqli_query($dbc, $query);

//confirm success
echo '<p>Thank you for your submission!</p>';
}
else {
echo '<p class="errmsg">There was a problem uploading your image.</p>';
}
}
@unlink($_FILES['fileImage']['tmp_name']);
}
else {
echo '<p class="errmsg">The screen shot must be a GIF, JPEG, or PNG image file no greater than 32KB in size.</p>';
}
}

有什么想法吗?

最佳答案

  1. 检查您的“图片”文件夹权限,例如将其设为 0777(所有人都可写)。
  2. 将“images/”路径更改为绝对服务器路径。

关于php - move_uploaded_file() 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2611930/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com