chupinette
chupinette

Reputation: 456

Which location to save uploaded files

I am using php and i have written codes to allow a user upload a file. For testing purposes, i have saved the file to D:/final/temp/test.xls. Then i generate another file and save it to the same location. This file can be downloaded by the user. But if an actual user would be using my application, where should the location point to? Thanks!

Upvotes: 0

Views: 289

Answers (1)

Brian Lyttle
Brian Lyttle

Reputation: 14579

You need to upload the file to a directory which is being served by your web server. You have 3 options:

  1. Find the directory where your PHP files are being served and save the files to that location, or a directory underneath.
  2. In your web server config, map the D:/final/temp/ directory to a website or virtual directory.
  3. Create a PHP file that reads the file from the D:/final/temp directory and serves it to the end user. This option is trickier to setup and has more gotchas in terms of performance.

The location which you upload to needs to have write permissions, and the web server also needs to be able to read files from this location.

Upvotes: 1

Related Questions