Early last year, I created a website that parses a CSV file and parses / displays it in a certain way for internal use. One page of this website provides an upload / download function so that the CSV file can simply be updated from the front end. This part has worked fine up until today. I must have changed something while working that has affected the download but for the life of me I can't think what.

I use a PHP copy function to get the file from a form and upload it to the server. This works fine, I can select a new CSV file on the front end web page I've created and it uploads fine. I then go to CPanel file manager, double check the file and I know it's the same new file that I've just uploaded due to changes I've made. When the PHP functions uploads it, it renames it with a certain name overwrites the old version. So to download it, the front end web page has a simple static link to the CSV file.

Now get this: since some point today, whenever I click that link, it downloads the old version of the file. I've rechecked everything I can think of literally about 25 times:

  • The website domain is an addon domain, the DNS is all correct.
  • The addon settings in CPanel still point to the folder that I'm using.
  • The link on the web page is absolutely correct, and is the same when I inspect the HTML code.
  • I've turned off caching in .htaccess, cleared my cookies for this site.
  • I tried deleting the CSV file altogether.
  • I've tried opening in incognito window

However, despite any and all of these, it still downloads the old file, and when I check CPanel the new file is there with the new details and the old one doesn't exist.

I thought I'd be clever: in CPanel I copied the file and renamed it: I tried to download it using the same style of link (just renamed) and but instead this takes me to the root web page of the site although I have no redirects set up.

I am completely stumped. I have rechecked multiple times that the link is correct, that I'm looking at the right file directory, that everything matches up. And it does. Just that somewhere, somehow, the wrong file is being downloaded and I have no idea where it's coming from.

  • Would it be helpful if I provided the links and / or screenshots that demonstrate my question? Wasn't sure if it's ok to post links here. – 5Diraptor Mar 31 '20 at 14:49
  • How about other possible caches? Is there a CDN involved? Have you cleared the cache of your web browser? Have you tried downloading with tools such as wget or curl? – Stephen Ostermiller Mar 31 '20 at 14:52
  • Hello @StephenOstermiller - thanks for the comments. I've already tried clearing cache, and also set .htaccess to not allow any caching. Haven't tried wget or curl, let me give that a go see if I get anything different. – 5Diraptor Mar 31 '20 at 14:58
  • Not sure how to use curl to download a file locally, and just looked at wget, is it a linux command? again not sure how to use it to download locally. Another obervation, I have 2 browsers open, one Vivaldi, the other Chrome incognito, and Vivaldi downloads the old version, Chrome downloads a blank csv, even though both refreshed just now. Weird. neither files exist on my server. – 5Diraptor Mar 31 '20 at 15:24
  • Both curl and wget are command line programs available for a variety of OS including Windows, Linux, and Mac. Wget typically saves a file by default when you call it with a URL: wget https://example.com/file while curl prints to the terminal by default but can be directed to a file curl -s https://example.com/file > file.csv. Curl can do nifty stuff like examining headers: curl --head https://example.com/file – Stephen Ostermiller Mar 31 '20 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.