I am testing out a new server.
My main site is BiddersSite.com, but we have been testing all the different functions of the script on the .net domain, and manage to clear up the problems with your help and a lot of trial and error. We have it down to one last problem, which after days of attempts to get it to work right, we havent solved the problem. So as our last resort we have turned to you oh mighty script guru and hope that we could run it by you. It may be something very obvious to an expert, while I have overlooked it time and time again.
The file works, just not completly, its within cgi-bin/auctions/upload.cgi file where users upload there items pictures. The script is meant to upload up to four pictures, and make a thumbnail of the 1st one to be stored respectively to:
/images/uploaddir/
/images/uploaddir/thumbs/
The script does upload the photo to the uploaddir, however its not saving a thumbnail image as it should to sub directory /thumbs.
The script seems to run the same with or without the use carp: When I had it report to browser, it didnt display an error. All the same, its still not writing the image file for the thumbnail image. Ive double checked my permissions as well. Nothing seemed to make any difference.
In case you need to see it work, from the hompage Multimedia file viewing and clickable links are available for registered members only!! You need to
or
!!
hit "sell" at the very top of the page, then select the third option - upload images at the bottom, this calls the upload.cgi, where you select a image file to upload, then preview the image, it shows you the image has been uploaded, then you would have to select gallery, featured, category featured, also it requires a catergory, begining price and username and password. We have setup username=Tester4 and password=testing for you. We know your time is valuable, and we thank you for your efforts with us.
Domain in question - Multimedia file viewing and clickable links are available for registered members only!! You need to
or
!!
This is the code of my upload.cgi file.
#!/usr/bin/perl
use CGI qw/:standard/;
$config{'currency'} = '$';
$config{'textuploadcharge'} = '0.00';
$config{'textuploadcharge2'} = '0.00';
$config{'textuploadcharge3'} = '0.15';
$config{'textuploadcharge4'} = '0.15';
$config{'sitename'} = 'bidderssite.net';
$config{'imageuploaddir'} = '/var/www/vhosts/bidderssite.net/httpdocs/images/uploaddir';
$config{'imageuploadurl'} = 'Multimedia file viewing and clickable links are available for registered members only!! You need to
or
!!
';
$config{'scripturl'} = 'Multimedia file viewing and clickable links are available for registered members only!! You need to
or
!!
';
$config{'closedays2'} = 90;
$config{'imagesize'} = 500;
$config{'colortablehead'} = '#E6E6E6';
$config{'bordercolor'} = '#0000FF';
$config{'bordercolor1'} = '#000000';
$config{'odd_row_color'} = '#FFFFFF';
$config{'even_row_color'} = '#EEEEEE';
$config{'header2'} =<<"EOF";
<HEAD>
<TITLE>$config{'sitename'}</TITLE>
</HEAD>
<FONT FACE=ARIAL><BODY TEXT=#000000 BGCOLOR=#FFFFFF LINK=#0000FF VLINK=#800080 ALINK=#FF0000>
<a href=/index.shtml><img border=0 src=/images/logo.gif></a><br><br><br><br>
EOF
@ext = qw(jpeg jpg gif bmp);
$| = 1;
$match = 0;
$encoding = 'multipart/form-data';
$q = new CGI;
print "Content-type: text/html\n\n";
print $config{'header2'};
print "<div align=center><center><table border=0 cellpadding=0 cellspacing=0 width=100% bordercolor=$config{'bordercolor'}>";
print "<tr><td width=100% bgcolor=$config{'colortablehead'} height=30><b> Select your picture(s) to upload (@ext - $config{'imagesize'} kb maximum)</b></td></tr></table></center></div><br>";
print $q->startform($method,$action,$encoding);
print "<center><font face=arial size=2><b>Upload Charge $config{'currency'}$config{'textuploadcharge'} - Image 1: </b></font>";
print $q->filefield(-name=>'upload_file1', -default=>'starting value', -size=>50, -maxlength=>180);
print "<br><font face=arial size=2><b>Upload Charge $config{'currency'}$config{'textuploadcharge2'} - Image 2: </b></font>";
print $q->filefield(-name=>'upload_file2', -default=>'starting value', -size=>50, -maxlength=>180);
print "<br><font face=arial size=2><b>Upload Charge $config{'currency'}$config{'textuploadcharge3'} - Image 3: </b></font>";
print $q->filefield(-name=>'upload_file3', -default=>'starting value', -size=>50, -maxlength=>180);
print "<br><font face=arial size=2><b>Upload Charge $config{'currency'}$config{'textuploadcharge4'} - Image 4: </b></font>";
print $q->filefield(-name=>'upload_file4', -default=>'starting value', -size=>50, -maxlength=>180);
print "<br>";
print $q->submit(-name=>'button_name', -value=>'Upload Image(s)');
print "</center>";
print $q->endform;
print "<hr width=80% size=1 color=$config{'bordercolor'}>";
print "<center><p><font face=arial size=2>Please click the \"Image Upload\" button only once,<br>Image Upload can take up to 5 seconds per image you upload.<br>Your images will appear below when finished.</font></center></p>";
print "<hr width=80% size=1 color=$config{'bordercolor'}>";
umask(000); # UNIX file permission junk
mkdir("$config{'imageuploaddir'}", 0777) unless (-d "$config{'imageuploaddir'}");
$file1 = $form{'upload_file1'};
$file2 = $form{'upload_file2'};
$file3 = $form{'upload_file3'};
$file4 = $form{'upload_file4'};
$uploadfile1 = $q->param('upload_file1');
$uploadfile2 = $q->param('upload_file2');
$uploadfile3 = $q->param('upload_file3');
$uploadfile4 = $q->param('upload_file4');
if ($ENV{'CONTENT_LENGTH'} >= $config{'imagesize'} * 1024) {
print "<p><div align=center><font face=arial size=2 color=FF0000><p>Error - The image file size is too large\!</font></p>\n";
print "<p><font face=arial size=2>Sorry but your upload image size can not be over $config{'imagesize'}k.</font></p>\n";
print "<p><font face=arial size=2>Please only upload images with a file size less than $config{'imagesize'}k.</font></p></div>";
exit 0;
}
if ($uploadfile1){
$uploadfile1 =~ /\w:[\\[\w- ]*\\]*([\w- ]*.\w{1,3})$/g;
$file1 = $1;
foreach $ext (@ext){
if (grep /$ext$/i,$uploadfile1){
$match = 1;
$type = $ext;
}
}
if ($match){
$newimage = ($config{'closedays2'} * 86400 + time);
$file1 = "$newimage.$type";
undef $bytesread;
open(OUTFILE, ">$config{'imageuploaddir'}/$file1")||&error("Can not open $config{'imageuploaddir'}/$file1. $!");
binmode OUTFILE;
while ($bytesread=read($uploadfile1,$buffer,1024)) {
print OUTFILE $buffer;
}
close (OUTFILE);
sleep 2; # Wait 2 seconds
}
else {
&error("<center><font face=arial size=2><b>Image format not supported.</b><p>$uploadfile1</p><b>Upload has failed.</b></font></center>");
}
}
if ($uploadfile2){
$uploadfile2 =~ /\w:[\\[\w- ]*\\]*([\w- ]*.\w{1,3})$/g;
$file2 = $1;
foreach $ext (@ext){
if (grep /$ext$/i,$uploadfile2){
$match = 1;
$type=$ext;
}
}
if ($match){
$newimage = ($config{'closedays2'} * 86400 + time);
$file2 = "$newimage.$type";
undef $bytesread;
open(OUTFILE, ">$config{'imageuploaddir'}/$file2")||&error("Can not open $config{'imageuploaddir'}/$file2. $!");
binmode OUTFILE;
while ($bytesread=read($uploadfile2,$buffer,1024)) {
print OUTFILE $buffer;
}
close (OUTFILE);
sleep 2; # Wait 2 seconds
}
else {
&error("<center><font face=arial size=2><b>Image format not supported.</b><p>$uploadfile2</p><b>Upload has failed.</b></font></center>");
}
}
if ($uploadfile3){
$uploadfile3 =~ /\w:[\\[\w- ]*\\]*([\w- ]*.\w{1,3})$/g;
$file3 = $1;
Theres more but I ran out of room....