CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Still Can't Upload a File...

 



Rivotti
User

Apr 11, 2000, 10:27 PM

Post #1 of 6 (1180 views)
Still Can't Upload a File... Can't Post

Hi:

Have posted, some days ago, "Can't Upload File". I have a program that grabs a file from a form( whit file upload tag ) and then saves it on my server. This program was working last time I used him. Now I'm tryin to use the same code in another program but it doesn't work. the code is<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

#!/usr/bin/perl
use CGI qw( :standard );

...

my $length;
my $size;
$dir='/home/web';
$file= new CGI->param('file_upload');
$file=~ m!([^/:\\]*)$!;
my $short_name = $1;

open (SAVE,">EXP/$short_name") &#0124; &#0124; die $!;
while ($size = read($file,$data,1024)) {
print SAVE $data;
close SAVE;

...</pre><HR></BLOCKQUOTE>
Can you see what I'm doing wrong?
Rivotti


Cure
User

Apr 12, 2000, 2:22 PM

Post #2 of 6 (1180 views)
Re: Still Can't Upload a File... [In reply to] Can't Post

Hi

To upload a txt file to your server.

#!/usr/bin/perl

use CGI;

$query = new CGI;

print $query->header;

$short_name="perl.txt";

$fh = $query->param('file-to-upload-01');
open(CURE, ">$short_name") or die "Could not open $shortname.$!";

while (<$fh> ) {

print CURE;
}
close(CURE);

Cure



Cure
User

Apr 12, 2000, 2:27 PM

Post #3 of 6 (1180 views)
Re: Still Can't Upload a File... [In reply to] Can't Post

Hi

# Copy a binary file to somewhere safe
open (OUTFILE,">>/usr/local/web/users/feedback");
binmode(OUTFILE);
while ($bytesread=read($filename,$buffer,1024)) {
print OUTFILE $buffer;
}
close $filename;

Cure


[This message has been edited by Cure (edited 04-12-2000).]


Rivotti
User

Apr 12, 2000, 3:40 PM

Post #4 of 6 (1180 views)
Re: Still Can't Upload a File... [In reply to] Can't Post

Hi Cure:

I'm using "use CGI qw( :standard )" because it's required by the code of the rest of the program. How can I still upload a file?

Thanks
Rivotti


Cure
User

Apr 12, 2000, 4:03 PM

Post #5 of 6 (1180 views)
Re: Still Can't Upload a File... [In reply to] Can't Post

Hi

#!/usr/bin/perl

use CGI qw/:standard/;

print header();

$short_name="perl.txt";

$fh = param('file-to-upload-01');
open(CURE, ">$short_name") or die "Could not open $shortname.$!";

while (<$fh> ) {

print CURE;
}
close(CURE);

Cure


Rivotti
User

Apr 12, 2000, 5:04 PM

Post #6 of 6 (1180 views)
Re: Still Can't Upload a File... [In reply to] Can't Post

Hi again:

Let me see. To do with "use CGI qw/:standard/;" I must print a header first, right? Ok. Can I use the same code you used with binmode for images?

Thanks in advance Smile
Rivotti

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives