0

I am doing upload and download script with php. For the upload part, I store the uploaded file, for example, 'my picture.jpg' above my 'htdocs/' with a random name. e.x.:

[-] htdocs
   |--[+] download
  [-] upload
   |--abcdef <<-- 'my picture.jpg' stored as 'abcdef'

The original file name and the new random name is linked by database.

In retrieving the file above, first I create random directory under 'htdocs/download/', copy the file there then rename it back to its original name before handing over the download link.

[-] htdocs
   |--[-] download
       |--[-] zyxwvu
           |--my picture.jpg
  [-] upload         ^
   |--abcdef  ->- copy

For big files, especially with multiple download request, there will be some unnecessary copy of the files.

My question is, how can I request apache to read the file 'upload/abcdef', and give the link as 'download/zyxwvu/my picture.jpg' so it can be downloaded without an extra copy?

2
Contributors
5
Replies
10
Views
8 Years
Discussion Span
Last Post by chu121su12
0

Maybe you can use symlinks? if you are on ubuntu though I don't know if that exists on windows

0

As I read about the symlinks, it converge to the point that i must create the link by script, isnt it? Ill try this one later.

Back to apache, then, is it possible to request the apache itself to read into another location? Because I would like very much to make this task be done by apache itself.

0

maybe this helps:
this is my virtualhost and as you can see I have all files from a certain dir (/usr/local/www/django/ninv) without copy paste them every time I make a change to that directory =)

<VirtualHost *:81>
    Alias /med /usr/local/www/django/ninv/med/
    Alias /admin-media /usr/local/www/django/ninv/admin/media/
    ServerName localhost
    ServerAdmin d@g.com

    DocumentRoot /usr/local/www/django/ninv/

    <Directory /usr/local/www/django/ninv/>
	Options Indexes FollowSymLinks MultiViews
	AllowOverride None
	Order allow,deny
	allow from all
    </Directory>

    WSGIScriptAlias / /usr/local/wsgi/scripts/django.wsgi

    <Directory /usr/local/wsgi/scripts>
    Order allow,deny
    Allow from all
    </Directory>

</VirtualHost>

hope this helps

you should only look at the documentroot and directory tags

Edited by Kruptein: n/a

0

doubled.. See next post.

Edited by chu121su12: double posting

0

I dont think i would use that. What I want is for apache to somehow alias the 'abcdef' as 'my picture.jpg' only when that file is requested. The alias should be deleted, say, after 1 hour after last download.

Using virtual directory will allow the files to be accessed anytime, while I store them using different name than the original.

I got the application to make alias for windows by sysinternals: junction. However it can only alias directories, so i would have to store the uploaded file without modifying the name. I've seen some CLI aliasing application but i haven't tested them yet.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.