Safari中的PHP move_uploaded_file函数错误但在Chrome中有效

时间:2017-09-13 22:36:26

标签: php google-chrome mysqli browser safari

以下代码在Chrome浏览器中成功上传图片,但在Safari中失败。 Safari是最新的,允许使用cookie。我哪里错了?

<form action="" method="post" accept-charset="utf-8" enctype="multipart/form-data">
<div class="upload-btn-wrapper">
                  <button class="btn-2"><i class="fa fa-camera" aria-hidden="true"></i>Select Image</button>
                  <input type="file" name="avatar"  id="avatarbtn"/>
                </div>

<button type="submit" name="usDet-1" class="btn-2" style="margin-top: 20px;">Save Details</button>
</form>

<?php
$Edavatar = $_FILES['avatar']['name'];
$fileTmpLoc = $_FILES["avatar"]["tmp_name"];
$fileType = $_FILES["avatar"]["type"];
$fileSize = $_FILES["avatar"]["size"];
$fileErrorMsg = $_FILES["avatar"]["error"];

$kaboom = explode(".", $Edavatar);
$fileExt = end($kaboom);

$newfilename = rand(10,999999999999).".".$fileExt;

$folder ='doc/users/user-folder/profile/img';

$moveResult = move_uploaded_file($fileTmpLoc, "$folder/$newfilename");

if ($moveResult != true) 
{
    // Profile image upload failed, this occurs on Safari browser only.

}
else
{
    // Works fine on Chrome Browser     


}
?>

var_dump($ _ FILES)结果

array(1){[&#34; avatar&#34;] =&gt; array(5){[&#34; name&#34;] =&gt; string(15)&#34; profile_img.jpg&#34; [&#34;类型&#34;] =&GT; string(10)&#34; image / jpeg&#34; [&#34; tmp_name的值&#34;] =&GT; string(14)&#34; / tmp / php9yHA7d&#34; [&#34;错误&#34;] =&GT; int(0)[&#34; size&#34;] =&gt; int(161313)}}

0 个答案:

没有答案