php文件上传代码不适用于iphone

时间:2015-10-28 18:24:08

标签: php iphone

我允许用户在我的php网站上的页面上传图片。它的工作正常,除了iphone,每个图像在同时上传多个图像时都是相同的。我无法弄清楚出了什么问题。这是我的上传代码:

if(isset($_POST['uploaded']))
{
    for($i=0; $i<count($_FILES['upload']['name']); $i++)
    {
        $uploadOk = 1;

        //Get the temp file path and extension
        $tmpFilePath = $_FILES['upload']['tmp_name'][$i];
        $imageFileType = pathinfo($_FILES['upload']['name'][$i], PATHINFO_EXTENSION);

        //Check file size
        if (filesize($_FILES['upload']['tmp_name'][$i]) > 2097150)
        {
            echo "<font color=red>Sorry, your file is too large. </font>";
            $uploadOk = 0;
        }

        //Allow certain file formats
        if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "pdf" && $imageFileType != "gif" 
            && $imageFileType != "JPG" && $imageFileType != "PNG" && $imageFileType != "JPEG" && $imageFileType != "PDF" && $imageFileType != "GIF") 
        {
            echo '<font color=red>Sorry, only JPG, JPEG, PDF, PNG & GIF files are allowed.</font>';
            $uploadOk = 0;
        }

        //Make sure we have a filepath
        if ($tmpFilePath != "" && $uploadOk == 1)
        {
            //Setup our new file path
            $newFilePath = "tempUpload/" . $_FILES['upload']['name'][$i];

            //Upload the file into the temp dir
            if(move_uploaded_file($tmpFilePath, $newFilePath)) 
            {
                //remember the file name by adding it to fileNameArray and increment the number of designs
                array_push($fileNameArray, $_FILES['upload']['name'][$i]);
                $numDesigns++;
            }
        }
        else
            echo "<font color=red> Your file was not uploaded<br></font>";
    }
}

0 个答案:

没有答案