图像上传在表单提交后会更改图像很多时间


image upload changes image lot of time after form submit

我遇到了一些麻烦。我有以下用于上传个人资料图像的脚本,用户第一次上传时,它工作正常,第二次它没有变化,您选择图像,提交表单,并且相同的图像显示为配置文件,而不是新的。我刚刚意识到,几个小时后,您进入该网站并且图像发生了变化,这是什么?是不是像在我的本地主机中一样提交时图像没有变化?

代码如下:

if (isset($_POST['parse_var'])){
if ($_POST['parse_var'] == "pic"){

// If a file is posted with the form
if ($_FILES['fileField']['tmp_name'] != "") { 
        $maxfilesize = 4109212;
    $target_dir = "users/$logOptions_id/profile.jpg";

        if($_FILES['fileField']['size'] > $maxfilesize ) { 
                    $error_msg = '<font color="#FF0000">ERROR: Your image was too large, please try again.</font>';
                    unlink($_FILES['fileField']['tmp_name']); 
        } else if (!preg_match("/'.(gif|jpg|png|jpeg)$/i", $_FILES['fileField']['name'] ) ) {
                    $error_msg = '<font color="#FF0000">ERROR: Your image was not one of the accepted formats, please try again.</font>';
                    unlink($_FILES['fileField']['tmp_name']); 
        } else {
      $newname = "profile.jpg";
              $place_file = move_uploaded_file($_FILES['fileField']['tmp_name'], "users/12/".$newname);

        }
     } 
 }
 }

提前感谢,我已经处理这个问题 2 天了,我不知道如何解决它。

我找到了解决方案,那就是图像被缓存,所以浏览器显示缓存的图像。解决方案是广告?以及图像 SRC 处.jpg后的兰特编号。

有哪些错误? 了解错误可能有助于解决问题。并检查您的文件夹权限。实时服务器上发生此类错误是因为文件夹没有足够的写入权限。

转到您的cpanel或管理服务器的任何内容,检查您的用户文件夹是否具有写入权限。