Closed moxita closed 8 years ago
A common and simple solution to this problem is to add a randomly generated query string to each request for the dynamic file. img src="file.png" /> Would become img src="file.png?var=11" /> Or img src="file.png?var=12" /> From the point of view of the web-server the same file is accessed, but from the point of view of the browser no caching can be performed.
The issue is here in your upload handler:
$newname = $id.'_'.$item.'.'.$ext;
echo $newname;
$uploader->newFileName = $newname;
First, you likely want to remove echo $newname;
as this is likely resulting in an invalid JSON response being returned to the browser.
If you just need a random file name to avoid overwriting another file, you could do something like this:
$ext = $uploader->getExtension();
$newname = uniqid('upfile_', true) . '.' . $ext;
$uploader->newFileName = $newname;
Hello,
Thank you so much for developing Simple-Ajax-Uploader!
It is working very well for me, except that I am unable to figure out how to change the filename. Here is the code on my page, mostly copied verbatim from your examples. I wonder if you could explain where I am going wrong? The file gets uploaded and saved fine, but it is found only as "/docs/_.pdf".
Here's my upload handler:
and here's the script from my head.php file