Solved

upload binary file (image file) to Web using Perl

Posted on 2000-02-16
3
214 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
  • 2
3 Comments
 
LVL 5

Expert Comment

by:PC_User321
ID: 2530689
0
 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

929 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now