You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Jeremy Le <je...@yahoo.com> on 2001/03/26 06:40:44 UTC

File Upload problem

I wrote an embperl script that uploads a file to a web
server. It works fine on Linux and Macs but not on
Windows. When I upload a file from a browser using
Windows 95/98, the file is uploaded to the web server
but it has 0 bytes in it. 
Here is part of the script that checks a file from
Windows.
Say,the file is: C:\Document\testing\helloworld.txt
...
[-
#check for "/" path (works just fine).

#check for "\" path (get 0 bytes instead of actual
bytes)

if($fdat{upfile} =~ m/\\/) {
$filename = (split(/\\/,$fdat{upfile}))[-1];
}
if(defined $filename) {
open FILE, "> /tmp/$filename";
while( read($filename,$buffer,32768)) {
print FILE $buffer;
}
close FILE;
}
-]
...
Any idea?
Thanks,
Jeremy


__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: File Upload problem

Posted by Gerald Richter <ri...@ecos.de>.
> I wrote an embperl script that uploads a file to a web
> server. It works fine on Linux and Macs but not on
> Windows. When I upload a file from a browser using
> Windows 95/98, the file is uploaded to the web server
> but it has 0 bytes in it.
> Here is part of the script that checks a file from
> Windows.
> Say,the file is: C:\Document\testing\helloworld.txt

At the first look the code seems to be ok.

What does $filename contain in this case ?

Does it work when you use a fix filename to write to instead of splitting it
out of the client side filename ?

You should note that the filename you get passed in is the local filename
from the client side, so it could be anything (not only a Unix or Windows
filename). So if you really want to use it you should make sure that it
doesn't contain any characters that compromises your security (e.g. .. etc.)

Gerald

-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org