Solved

upload binary file (image file) to Web using Perl

Posted on 2000-02-16
3
243 Views
Last Modified: 2008-02-20
Did anybody know where can find perl sample program for uploading image file (binary file) to web site through Web page?
0
Comment
Question by:jamestse
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
guadalupe earned 300 total points
ID: 2531127
This will work as long as you have access to the dir "tmp" if not just edit to a dir you have access to.  And you will need the module CGI.pm


##HTML for (upload)
{

}
<form ENCTYPE="multipart/form-data" action="/cgi-bin/upload.pl" Method=POST>
Attach:<input name="file" type="file">

<INPUT TYPE=SUBMIT>
</form>


#perl for upload
#!/usr/local/bin/perl

use CGI;

$query=new CGI;

$file_path = $query->param('file');


print $file_path,"\n";

$file_path =~ m!.*?!/?([^/]+);

$upload_file = $1;

print "Content-type: text/html\n\n";

`rm /tmp/$upload_file`;
open(MYFILE,"> /tmp/$upload_file") || die $!;
binmode MYFILE;
while($bytesread=read($file_path,$data,1024)){
  $size+=$bytesread;
  print MYFILE $data;
}
close(MYFILE);
close($file_path);

`chmod 777 /tmp/$upload_file`;
print $size;

print "Done Reading";
0
 
LVL 3

Expert Comment

by:guadalupe
ID: 2536522
So how did that go...
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question