|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have alot of documents on my hard drive that are called data.1.1121.1 etc. In a mysql database all the original names are stored and are linked to the actual names on the harddrive so data.1.1121.1 -> bwaa.doc
The problem is that, when the user wants to download the file i want the file to be saved as the original. So i want the data.1.1121.1 file to be offered to save as bwaa.doc. Is there a way to do so? (with CGI ofcourse) tnx in advance BuTcH! |
|
#2
|
|||
|
|||
|
I hope this is what you wanted
############################################# #!/usr/local/bin/perl # fill in $dir_path to your data.1.1121.1 # fill in $url_path to where your data.1.1121.1 and bwaa.doc reside # in this case, I assume they both reside in same directory $dir_path = "/path/to"; $url_path = "http://www.yourdomain.com/data"; print "Content-type: text/htmlnn"; if ($ENV{'QUERY_STRING'}) { $link = "$ENV{'QUERY_STRING'}"; $ls = `ls -Al $dir_path/$link`; ($permission,$nlink,$owner,$group,$size,$month,$day,$time,$filename,$arrow,@file) = split(/s+/, $ls); if ($arrow eq "") { print "No Symlink!<br>n"; print "Please right-click and select "Save link as"...<br>n"; print "<a href="$url_path/$link">$link</a>n"; exit(0); } foreach $path (@file) { @dir_path = split(///, $path); $actual_file = pop @dir_path; print "Please right-click and select "Save link as"...<br>n"; print "<a href="$url_path/$actual_file">$link</a>n"; } } else { print "No Stringn"; } [This message has been edited by freebsd (edited April 22, 2000).] |
|
#3
|
|||
|
|||
|
I forgot to mention something..
Let say this script is to be named script.pl, you are supposed to call it thru query string like this: http://www.domain.com/cgi-bin/script.pl?data.1.1121.1 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Downloading a file. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|