Picasso加载第一个上传的图像,名称相同,但浏览器加载下一个

时间:2017-12-10 11:29:34

标签: php android

我上传的图片名称和扩展名相同 当图像存在于上传目标文件夹中时,我将其取消链接,然后移动具有相同名称的文件

chmod($ Upload_path,0755)返回true,
unlink($ Upload_path)返回true 和move_uploaded_file也返回true

问题是当我尝试下载文件时:

1 - 在Chrome和Firefox浏览器中,下载了真实图像,但是之后     虽然(也许是5秒或更长时间),为什么过了一会儿?!

  

编辑:20秒后有时会加载新更新的图像   铬,有时45秒后

2 - 在Android程序中,使用Picasso,之前的图像仍然是     下载
    同时确保以前的图像是真正下载而不是     新上传的图像具有相同的名称(与之无关     毕加索的缓存):
    A - 我删除了Picasso的缓存     B - 使用另一台干净的手机
    C - 制作毕加索的记忆和网络政策,以免使用缓存
.networkPolicy(NetworkPolicy.NO_CACHE,NetworkPolicy.NO_STORE) .memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE)

那么为什么毕加索仍在下载以前的图像而不是浏览器?

3 - 在服务器端,我使用Core FTP LE来验证文件
    当我点击上传的文件时,会显示一条消息,指示该消息     文件夹已包含名为...的文件(这是上传的名称     文件)     当我取消链接文件并且那里没有任何迹象时,到底是什么     这条消息?
如何完全删除以前的文件?

提前致谢

编辑:
PHP代码:

        if(file_exists($Upload_path)) 
        {
            echo "\nPresent File Should Be Deleted";
            if (chmod($Upload_path,0755) === true)// Change the file permissions if allowed
            {
               echo "\nchmod true";
            }
            else
            {
               echo "\nchmod false";
            }

            if(unlink($Upload_path) === true)// remove the file
            {
               echo "\nunlink true";
            }
            else
            {
               echo "\nunlink false";
            }

        }

        if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $Upload_path)) {
            echo "\nMove successful";
        } 
        else
        {
            echo "\nMove failed";
        }

Android代码:

FileInputStream fileInputStream = new FileInputStream(sourceFile);

            URL url = new URL(upLoadServerUri);

            // Open a HTTP  connection to  the URL
            conn = (HttpURLConnection) url.openConnection();
            conn.setDoInput(true); // Allow Inputs
            conn.setDoOutput(true); // Allow Outputs
            conn.setUseCaches(false); // Don't use a Cached Copy
            conn.setRequestMethod("POST");
            conn.setRequestProperty("Connection", "Keep-Alive");
            conn.setRequestProperty("ENCTYPE", "multipart/form-data");
            conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + boundary);

            conn.setRequestProperty("uploaded_file", fileName);

            dos = new DataOutputStream(conn.getOutputStream());

            dos.writeBytes(twoHyphens + boundary + lineEnd);


            int length = fileInputStream.available();

            dos.writeBytes(lineEnd);

            // create a buffer of  maximum size
            bytesAvailable = fileInputStream.available();

            bufferSize = Math.min(bytesAvailable, maxBufferSize);
            buffer = new byte[bufferSize];

            // read file and write it into form...
            bytesRead = fileInputStream.read(buffer, 0, bufferSize);

            while (bytesRead > 0) {

                dos.write(buffer, 0, bufferSize);
                bytesAvailable = fileInputStream.available();
                bufferSize = Math.min(bytesAvailable, maxBufferSize);
                bytesRead = fileInputStream.read(buffer, 0, bufferSize);

            }

            // send multipart form data necesssary after file data...
            dos.writeBytes(lineEnd);
            dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);

            // Responses from the server (code and message)
            serverResponseCode = conn.getResponseCode();
            String serverResponseMessage = conn.getResponseMessage();

            Log.i("BBBuploadFile", "HTTP Response is : "
                    + serverResponseMessage + ": " + serverResponseCode);

            if (serverResponseCode == 200) {

                Log.e(TAG, "Complete ");
            }

0 个答案:

没有答案