• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 277
  • Last Modified:

Saving a binary file (a gif) uploaded from user

I need to give people the chance to upload a picture of themselves and then i need to save it with a name i make up.  The picture would come from their computer, not the net.   I don't have permission to an anonymous ftp for the client. How would I do this, i'd rather not use any modules, i haven't been able to get one working right yet, but if there is no other way fine.  Thanks a lot for the help.
0
idadan
Asked:
idadan
1 Solution
 
b2piCommented:
Is this supposed to be web based?
0
 
idadanAuthor Commented:
yeah,
0
 
idadanAuthor Commented:
Adjusted points to 150
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
mitekCommented:
Are you using IIS ? If not, which webserver ?
0
 
idadanAuthor Commented:
apache, its unix, i think,
0
 
RoboBobCommented:
You can do this using file input, you need a web page that includes a file input in the form...

<FORM METHOD=POST ACTION="$ENV{'SCRIPT_NAME'}" ENCTYPE="multipart/form-data">
File: <INPUT TYPE=FILE NAME=file>
<INPUT TYPE=SUBMIT>
</FORM>

Then you need a perl script that can read in the data from the form, like this:

#!/usr/local/bin/perl -w
use CGI;

$cgi = new CGI;

open(OUT,"> $filename");
while($bytesread = read($cgi->param('file'), $buffer, 1024)) {
    print OUT $buffer;
}
close(OUT);

See the documentation for the CGI module ('perldoc CGI') for more information...
0
 
idadanAuthor Commented:
Ok, so filename would be the name that i want to call the file, and where would that get saved to? thanks.
0
 
RoboBobCommented:
It would get saved whereever you told it to, if you did
$filename = "/tmp/foobar", then it would get saved in the file /tmp/foobar.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now