×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Uploading image via browser ????

Uploading image via browser ????

Uploading image via browser ????

(OP)
Hi !

Is there a very simple way to upload .jpg or .gif images via IE and NS browser to selected directory ???

...and if is, how can i make that ?

Please help me !!!

RE: Uploading image via browser ????

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.

#!/usr/local/bin/perl
# author:  
# date:    
# Purpose: figure out how to use CGI.pm to upload file via
# the browser.
##############################################################
use CGI;
$thisCGI = '/path/to/your/file/upload';# change for your situation

$query = new CGI;
print $query->header,$query->start_html(-title=>"UPLOAD THIS");
print $query ->start_multipart_form('POST',"$thisCGI");

print "Enter or Browse to the file you would like to upload.<BR>\n";
print $query->filefield(-name=>'fileID',
          -size=>50,
         -maxlength=>80);

my $fileID = $query->param('fileID');
@pathName = split(/\\/,$fileID);
$newFile = '/where/you/want/to/put/the/file/';# change for your situation
$newFile .= pop(@pathName);

if ($fileID)
     {
     open(OPF,">$newFile") ¦¦ &showError("Failed to open OPF, $!");
     while ($bytesread=read($fileID,$buffer,2048)) { print OPF "$buffer"; }
     $type = $query->uploadInfo($fileID)->{'Content-Type'};
     print "<BR>Upload of $newFile of type $type Successful<BR>\n";
     }

print '<BR>',$query->submit('doWhat','uploadMe');
print $query->end_form;
print $query->end_html;

sub showError
    {
    my @error = @_;
    print "<CENTER><font color=\"\#ff4500\">Fatal ERROR - @error</font><BR>\n";
    print "Submission aborted - your data was not saved!!<BR>\n";
    print "Please use the BACK button to return to the previous page<BR>\n";
    print "and correct the error.<BR></CENTER>\n";
    print $query->end_form,$query->end_html;
    exit;
    }




keep the rudder amid ship and beware the odd typo

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close