PERL Upload Files
Code:
#!/usr/bin/perl Now the form is standard form with a file input and i'm positive the name value is equal to "upload" Also I have chmodded the directory to 777 so it should be able to write even as user apache. The problem is this: no matter what file is sent to it it always writes 0 bytes. I sent a 50 MB file and it took a while, which implies it was uploading, as well as a simple text document. Both wrote 0 bytes. Anyone know whats going on? EDIT: Evidently FireFox works fine to upload files, but IE fails. Any idea why IE would fail on this? |
I think you need to use the read call.
Try this: Code:
#!/usr/bin/perl |
Well I tried what you have there... but it still doesn't work in IE. Works perfectly in FF though!
|
does your form html tag include enctype="multipart/form-data" like this?
<form name="form" method="post" enctype="multipart/form-data" action=""> I don't know what the browser would have to do with the cgi script though that has me curious. |
Code:
<FORM ACTION="/cgi-bin/upload.pl" METHOD="post" ENCTYPE="multipart/form-data"> |
try add a : print "$filename";
right before the reg exp to see how IE and FF see the filename |
Internet Explorer:
Before REGEX: C:\Documents and Settings\David\Desktop\test.txt After REGEX: test.txt FireFox: Before REGEX: test.txt After REGEX: test.txt |
It has been a while since I worked with perl but I think you need a serparate varible for the filehandle. because you clean up filename and then try to us it as a handle
Code:
#!/usr/bin/perl |
No go. It still is giving 0 bytes in IE.
|
Try the script posted by spoody_goon, but rather of
use $query->param() to get the file handle, use the CGI method $query->upload() : Code:
$filehandle = $query->upload("upload"); |
Remember, while doing CGI
tail -f /var/apache/logs/error_log It's this: Code:
$filename =~ s/.*[\/\\](.*)/$1/; firefox is clever enough to convert back for you. save the name first. This works for me: Code:
#!/usr/bin/perl |
Hey thanks bigbears, that works great!
|
All times are GMT -5. The time now is 02:20 AM. |