【问题标题】:PHP Fatal error with uploading file from iphone从 iphone 上传文件时出现 PHP 致命错误
【发布时间】:2018-01-11 22:31:54
【问题描述】:

我正在尝试创建一个网页以从 iPhone 的照片库上传图像或使用 iPhone 的相机拍摄图像。

This is the error message on my iphone

这是上传图片的html代码

<html>
<form action="test_upload_image_results.php" method="post" enctype="multipart/form-data">
    Select image to upload:
    <br><input type="file" name="imageUpload" id="imageUpload">
    <br><br><input type="submit" value="Upload Image" name="submit">
</form>
</html>

这是用于上传图片的php代码(test_upload_image_results.php)

<html>
<body>

<?php
print_r($_FILES);

$tmpName = $_FILES["imageUpload"]["tmp_name"];
$destDir = "uploads/";

if (!is_dir($destDir))
{
    throw new Exception('Destination is not a directory.');
}

if (!is_writable($destDir))
{
    throw new Exception('Destination directory is not writable.');
}


$destination = $destDir.basename($_FILES["imageUpload"]["name"]);

if (is_file($destination))
{
    throw new Exception('Destination filename already exists.');
}



if (move_uploaded_file($tmpName, $destination))
{
    echo "done";
}
else
{
    throw new Exception('Unable to move file.');
}

?>

</body>
</html>

抱歉,这是一个非常初级的问题。

【问题讨论】:

  • UPLOAD_ERR_INI_SIZE 值:1;上传的文件超过了 php.ini 中的 upload_max_filesize 指令。

标签: php iphone file-upload


【解决方案1】:

因为你的 php ini config upload_max_filesize 小于上传图片的大小

尝试在php.ini中将upload_max_filesize改成更大的

有关更多信息,请参阅 php.net doc http://php.net/manual/en/features.file-upload.errors.php 上的文件 eupload 错误代码

【讨论】:

  • 感谢您推荐的解决方案 :)
【解决方案2】:

查看错误,$imageUpload['tmp_name']没有设置值,大小为0——图片还没有上传

错误1表示

"上传的文件超过了php.ini中的upload_max_filesize指令"

http://php.net/manual/en/features.file-upload.errors.php

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-04
    • 1970-01-01
    • 2015-03-30
    • 2019-04-17
    相关资源
    最近更新 更多