views:

43

answers:

1

hello! 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!

+1  A: 

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.

BrianLy
I tried to save the file to C:/xampp/htdocs/foldername/tmp. but i am having an error : you may be trying to access a read only location.
chupinette
You need to set the permissions on C:/xampp/htdocs/foldername/ to let you write files to that location. On Windows you can right-click a directory in Explorer and go to Properties->Permissions. The user which the web server is running as needs to have permission to write to the directory. You can find the user by looking at the processes view in Task Manager. If configured as a service look at the Service Manager properties for the service.
BrianLy