Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

upload binary file (image file) to Web using Perl

Posted on 2000-02-16
3
Medium Priority
?
251 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 600 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
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

688 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