Gossamer Forum
Home : General : Perl Programming :

UPLOAD - Problem !!

Quote Reply
UPLOAD - Problem !!
Hello,

i still have the same problem I use a perl-script to upload pictures but just the name of the picture for example "picture.gif" is written in the path -->> files without any Bytes ????

it looks like this

#!/usr/bin/perl

use strict;
use CGI;
my $directory = "../files/";

my $q = new CGI;
print $q->header, $q->start_html('Upload');

my ($filename) = $q->param('file') || "";

my $serverFile = $directory . (split(/[\\\/]/, $q->param('file')))[-1];



if (-e $serverFile){
print ("Datei existiert bereits\n");
}
else {
print ("Datei geschrieben: $serverFile<BR>\n");


my $buffer;
open (FILE,">$serverFile");
while (my $bytesread=read($filename,$buffer,1024)) {
print FILE $buffer;
}
close (FILE);

}


print $q->end_html;



if someone have an idea it will be greatfull

thanx

Beni


Quote Reply
Re: UPLOAD - Problem !! In reply to
I don't understand what you mean.

Instead of creating $serverFile you can just append the file name onto $directory like.....

$directory .= (split(/[\\\/]/, $q->param('file')))[-1];


Paul
Installations:http://wiredon.net/gt/
Support: http://wiredon.net/forum/

Quote Reply
Re: UPLOAD - Problem !! In reply to
i mean that the script works but i don't know why just the name of the picture will be written ??
i get an empty file in the path ../files

the HTML-Page looks like this:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF">
<form action="upload.pl" name="upload" enctype="multipart/form-data">
<input type="file" name="file" enctype="multipart/form-data" value="file">


<input type="submit" name="Button" value="Abschicken">
</form>
</body>
</html>

Quote Reply
Re: UPLOAD - Problem !! In reply to
You don't need this bit in red as you already have it in the form tag....

<input type="file" name="file" enctype="multipart/form-data" value="file">

Also I don't think you need......

<input type="submit" name="Button" value="Abschicken">




Paul
Installations:http://wiredon.net/gt/
Support: http://wiredon.net/forum/

Quote Reply
Re: UPLOAD - Problem !! In reply to
The problem is that your form is going to be submitted as a GET request, not the "POST" request required for multipart.

Add method="post" to you <form> tag.

Hope this helps!


Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: UPLOAD - Problem !! In reply to
THANK YOU very much !!

this was the key the --- method="post"

sorry for this

ciao

Beni

Quote Reply
Re: UPLOAD - Problem !! In reply to
Ewww can't believe I missed that - I was too busy focusing on what was there that shouldn't be, not what should be there that wasn't....


Paul
Installations:http://wiredon.net/gt/
Support: http://wiredon.net/forum/