Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 3rd, 2000, 03:24 AM
DaButcher DaButcher is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Posts: 4 DaButcher User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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!

Reply With Quote
  #2  
Old April 21st, 2000, 02:47 PM
freebsd
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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).]

Reply With Quote
  #3  
Old April 21st, 2000, 02:59 PM
freebsd
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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


Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Downloading a file.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT