Click to See Complete Forum and Search --> : cgi script upload photos probem


julieowen24
10-02-2003, 03:46 PM
Hi,

I am trying (very hard) to create a page where users of my site can upload there own photos, I have a few books on perl and CGI's to help me.
I have managed to get a normal form to work fine and email to me, so I assume I have all the necessary things to make a an upload page.

I have used the tutorial out of the book this is my form

<html><head><title>Uploading Files</title></head><body>
<form action="/cgi-bin/uploading.cgi"method="post" enctype="multipart/form-data">
What file would you like to upload
<input type="file"name="uploadfile"size="30">
<input type="submit">
</form></body></html>

This page works ( I think) it will allow me to browse my hard drive and select a file to upload.

The script I have done so far should do no more than print a page saying you have selected to upload xxxx file ( I got stuck at stage 2 and there are loads more stages to go before I am finished)

I then press submit and get a local 500 error, I had these when I first started me email form and it turned out that my permissions were wrong, I have checked these and the script is set to 755 and the cgi bin is set to 755, I assume this is correct.
Should I have another folder I made one called uploads but it is in no way linked to this script

This is my script

#!/usr/bin/perl
use CGI::Carp 'fatalsToBrowser';
use strict
use CGI ':standard';

print "content-type:text/html\n\n";

my $file=param('uploadfile');

if ($file) {
print "<p>you want to upload
<b>$file</b>";
} else {
print "No file chosen";
}
print '</body></html>';

it is called uploading.cgi and I have linked it from my form the same way as I have linked my form that works.
The only difference is the
use strict
and
use cgi standard.
I have included use CGI::Carp 'fatalsToBrowser'; as I found this in another reply on this forum, however it didn't change anything for me.

I have a feeling and I may be way off base here it is something to do with CGI pm and perl 5, I don't have these on my bit of the server, but if I go up into the admin side I see that it is there, I thought this would mean I have access to it as this is what happened in my perl form that works. Do I have to link there some how, if so how
I have looked everywhere about this PM and perl LIB to be honest I really don't understand it, I am willing to download it to my site if needs be, as long as that means I don't have to be connected for my form to work for others and if someone tells me where to put it (politely)

Please help me any and all suggestions are greatly received,

If you need further information on anything let me know, and i will post it.
I have posted a lot as I don't know what is relevant and what is not to solve my problem

jimr451
10-10-2003, 09:04 AM
Sounds like you need some background material. Here's an article that might help you:

http://www.sitepoint.com/article/474

It's got some basic perl code, and walks you through the basics.

Hope this helps.

-Jim

julieowen24
10-10-2003, 11:46 AM
Thank you,

The article has cleared up quite a few points for me, THanks for your time.

Julie