View Full Version : Problem with cgi script
fastroke
09-18-2004, 12:21 AM
For days I tried to make this cgi script work:
http://www.indeedvideo.com/cgi-bin/upload.cgi
I really tried everything
All permissions are open, script saved the right way, uploaded in ASCII...good paths...
Please let me know if you have any idea of what the problem could be.
Here's what it looks like:
#!/usr/bin/perl
use CGI;
$Data = "/home/httpd/vhosts/indeedvideo.com/upload";
$filename = $query->param("photo");
$email_address = $query->param("email_address");
@good_extensions = ('gif', 'jpg', 'jpeg',);
$redirect = <http://www.indeedvideo.com>;
$max_size = 50000;
$max_num_files = 3;
$auto_rename = 1;
$filename =~ s/.*[\/\\](.*)/$1/;
$upload_filehandle = $query->upload("photo");
open UPLOADFILE, ">$upload_dir/$filename";
while ( <$upload_filehandle> )
{
print UPLOADFILE;
}
close UPLOADFILE;
print $query->header ( );
print <<END_HTML;
<HTML>
<HEAD>
<TITLE>Thanks!</TITLE>
</HEAD>
<BODY>
<P>Thanks for uploading your photo!</P>
<P>Your email address: $email_address</P>
<P>Your photo:</P>
<img src="http://www.indeedvideo.com/upload" border="0">
</BODY>
</HTML>
END_HTML
mlseim
09-18-2004, 01:59 AM
What does the form look like?
Give us a link to the form where the user selects the file to upload.
Your form is going to need a particular ENCTYPE to make it work.
It would look something like this:
<form method='post' action='/cgi-bin/upload.cgi' ENCTYPE='multipart/form-data'>
.
. input tags here
.
</form>
fastroke
09-18-2004, 02:29 AM
The form is here:
http://www.indeedvideo.com/upload.htm
There is a form action but I don't know if I should enter the www... or server path. I tried so many things...
Thanks alot
mlseim
09-18-2004, 05:14 PM
Does your host allow PHP?
There is a PHP image upload script that is so much easier to use.
Otherwise, do a Google search for a different Perl file upload script.
Here's the simple PHP script.
This is the HTML form that calls the PHP script:
in this example, you can upload up to 3 files.
========================================================
<html><head></head>
<body>
<form action='process.php' method='post' enctype='multipart/form-data'>
<input type='hidden' name='MAX_FILE_SIZE' value='1000000'>
<input type='hidden' name='num' value='3'>
Select File: <input type='file' name='file1'><br>
Select File: <input type='file' name='file2'><br>
Select File: <input type='file' name='file3'><br>
<input type='Submit' value='Upload'>
</form>
</body>
</html>
========================================================
... and here is the php script, called "process.php".
Both of these snippets will be placed in your main HTML directory.
Create a sub directory called "uploads" and CHMOD to 777.
========================================================
<?php
//Get the number of files to be uploaded
$num = $_POST['num'];
//Start the Loop
for ($x = 1; $x <= $num; $x++)
{
//Make sure a file has been selected for upload
if (is_uploaded_file($_FILES['file'.$x]['tmp_name']))
{
//Get the size of the current file
$size = $_FILES['file'.$x]['size'];
//Make sure that this file is <= to 100KB
if ($size <= 100000)
{
//Move the uploaded file to the directory called 'uploads'
if (move_uploaded_file($_FILES['file'.$x]['tmp_name'],'uploads/'.$_FILES['file'.$x]['name']))
{
//Display message
echo "File: ".$_FILES['file'.$x]['name'] . " uploaded.<BR>";
}
else
{
//Unable to move file
echo "File: ".$_FILES['file'.$x]['name']. " error moving file.<BR>";
}
}
else
{
//File too large
echo "File: " . $_FILES['file'.$x]['name'] . "File Too Large.<BR>";
}
}
else
{
//No file selected
echo "No File Selected.<BR>";
}
} //End of loop
?>
========================================================
fastroke
09-18-2004, 07:02 PM
Yes, PHP is listed in the services
I tried it. It doesn't work but at least it give a good idea of where the problem could be. I'll keep working on it for a while
http://www.indeedvideo.com/uploads/upload.htm
I already tried 4 cgi that I got on google, I really don't know what's my problem.
Here's the services of my server:
Apache ASP support Yes
SSI support Yes
PHP support Yes
CGI support Yes
mod_perl support Yes
mod_python support No
ColdFusion support No (ColdFusion is not supported by the license key)
Web statistics Yes
Custom Error Documents No
Thanks anyway
Sonny
mlseim
09-19-2004, 05:41 PM
Are you familiar with the CHMOD command?
This is where you give permissions for the scripts, and directories.
I'm thinking that you may not be setting the permissions correctly.
With your FTP program, read the help section on setting CHMOD.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.