php - 上载图片错误

标签 php debugging image-processing error-handling

大家好,我正在尝试将图像上传到指定目录,并且所有输出结果都是“上传文件时出错,请重试!”

$upload_dir = "blog/wp-content/uploads/products";    
if (file_exists($upload_dir) && is_writable($upload_dir)) {
    echo "Directory exists and is fine....";
}
else {
    echo "Upload directory is not writable, or does not exist.";
}

$target_path = "blog/wp-content/uploads/products/";

$target_path = $target_path . basename( $_FILES['image_file']['name']); 

if(move_uploaded_file($_FILES['image_file']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['image_file']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";

}

有任何想法吗?

最佳答案

如果未收到警告,则这是唯一的原因:If filename is not a valid upload file, then no action will occur, and move_uploaded_file() will return FALSE.文档中的引号。

使用.is_uploaded_file检查上传。

关于php - 上载图片错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6198607/

相关文章:

php - 以折线图显示数据库的一些数据

php - Cakephp 表单输入自动完成功能

c++ vector 类中的调试中断

C 打印不需要的随机字符

Php路由器,从uri中提取 key

php - Laravel 4 一个接口(interface)同时具有多个实现

c++ - 编译器会为相同的源生成不同的 .pdb 文件吗

python - 如何使用 scikit-image 反转黑白?

c# - 如何以最快的方式做到这一点?图像阵列

python - TesseractNotFoundError : tesseract is not installed or it's not in your path