Hi !<br><br>Is there a very simple way to upload .jpg or .gif images via IE and NS browser to selected directory ???<br><br>...and if is, how can i make that ?<br><br>Please help me !!!
This is functional but to simple. Allowing users to upload stuff is a little dangerous. You should probably pay attention to file types. See the docuemtation for CGI.pm for more.<br><br>#!/usr/local/bin/perl<br># author: <br># date: <br># Purpose: figure out how to use CGI.pm to upload file via <br># the browser.<br>##############################################################<br>use CGI;<br>$thisCGI = '/path/to/your/file/upload';<font color=red># change for your situation</font><br><br>$query = new CGI;<br>print $query->header,$query->start_html(-title=>"UPLOAD THIS"<br>print $query ->start_multipart_form('POST',"$thisCGI"<br><br>print "Enter or Browse to the file you would like to upload.<BR>\n";<br>print $query->filefield(-name=>'fileID',<br> -size=>50,<br> -maxlength=>80);<br><br>my $fileID = $query->param('fileID');<br>@pathName = split(/\\/,$fileID);<br>$newFile = '/where/you/want/to/put/the/file/';<font color=red># change for your situation</font><br>$newFile .= pop(@pathName);<br><br>if ($fileID)<br> {<br> open(OPF,">$newFile" ¦¦ &showError("Failed to open OPF, $!"<br> while ($bytesread=read($fileID,$buffer,2048)) { print OPF "$buffer"; }<br> $type = $query->uploadInfo($fileID)->{'Content-Type'};<br> print "<BR>Upload of $newFile of type $type Successful<BR>\n";<br> }<br><br>print '<BR>',$query->submit('doWhat','uploadMe');<br>print $query->end_form;<br>print $query->end_html;<br><br>sub showError<br> {<br> my @error = @_;<br> print "<CENTER><font color=\"\#ff4500\">Fatal ERROR - @error</font><BR>\n";<br> print "Submission aborted - your data was not saved!!<BR>\n";<br> print "Please use the BACK button to return to the previous page<BR>\n";<br> print "and correct the error.<BR></CENTER>\n";<br> print $query->end_form,$query->end_html;<br> exit;<br> }<br> <p> <br><a href=mailto: > </a><br><a href= > </a><br> keep the rudder amid ship and beware the odd typo
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.