Closed Thread Icon

Preserved Topic: image upload: (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=21073" title="Pages that link to Preserved Topic: image upload: (Page 1 of 1)" rel="nofollow" >Preserved Topic: image upload: <span class="small">(Page 1 of 1)</span>\

 
axleclarkeuk
Paranoid (IV) Inmate

From: Swansea, Wales, UK
Insane since: Aug 2001

posted posted 09-24-2001 20:39

I have a CGI script that uploads an image to a specified directory on a server, the problem is, its seems to upload the pic, but it is 0 bytes, the filename is in the directory, but only the name ??

Any ideas ?


bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 09-24-2001 20:57

Got the script?

Doesn't seem to be a file permissions issue if it actually creates the file but I could be wrong.



:[ Computers let you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila. ]:

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 09-24-2001 21:04

Yeah, show us the script so that we can analyze it...

axleclarkeuk
Paranoid (IV) Inmate

From: Swansea, Wales, UK
Insane since: Aug 2001

posted posted 09-24-2001 22:31

here ya go guys !!


+++++++SCRIPT STARTS HERE+++++++++++++


#!/usr/bin/perl


$Data = "/home/866/prestige/www.prestigemotors.co.uk/public_html/car_images";


# On your server, create a directory where this program will write the files
# to. Make sure you CHMOD this directory to 777. If you do NOT specify a $Data
# directory, the program will attempt to write to the web root directory.
# NOTE: YOU SHOULD ALWAYS SPECIFY A DIRECTORY TO STORE THE UPLOAD

@good_extensions = ('gif', 'jpg', 'jpeg', 'png');
# If you want to limit the types of extension that can be uploaded, specify them
# here by adding them to the array. For example, if you wanted to permit only
# the upload of gif's, jpg's and png's, then you would set the above array to
# look like this:
# @good_extensions = ('gif', 'jpg', 'jpeg', 'png');
#

@bad_extensions = ();
# If you want to permit the upload of all file types with only certain exceptions,
# then specify those extensins in the bad_extensions array. This means that if set
# this array to contain .exe, .pl, .cgi files, then the program will only store a
# file if the extension of that file is NOT found in this array.
# To set the array to exclude these sample extensions, you would set it like this:
# @bad_extensions = ('exe', 'cgi', 'pl');
#

# NOTE: If you specify both @good_extensions and @bad_extensions, then
# the settings in @bad_extensions will be ignored and the program will
# use @good_extensions as it's refrence.

$redirect = "";
# When the upload of files is complete, the program must print someting out on the
# browser screen. Set the $redirect variable to the full URL (don't forget the http://)
# that you want the person taken to once the program is finished. If you don't specify
# a URL here, the program will print out a simple upload summary page.

$max_size = 500;
# Set the maximum size of each file that is permitted. For example, if you only want
# files to be uploaded that are under 50Kb in size, set the value to:
# $max_size = 50;
# If you set the value to zero, remove it or comment it out, then the size of the
# uploaded file will NOT be checked.

$max_num_files = 5;
# You must specify the maximum number of files that can be uploaded at one time. You
# can set this to any number you want but be realistic. The limit before the server
# times out will depend on the maximum size of the upload. I have tested this program
# with ASCII files up to 8MB in size successfully but that was on a particularly
# robust server. I recommend that you set this no higher than 5 if you are going to
# be using this for larger binary files such as images or executables or word docs, etc.
# If you remove, comment out or set this value to zero, the program will default the
# value to 1 file.

#
#######################################################################################
#
# DO NOT EDIT ANYTHING BELOW THIS LINE
# UNLESS YOU KNOW WHAT YOU ARE DOING
#

if(($ENV{'QUERY_STRING'} =~ /^debug/) && !$no_debug) {
print "Pragma: no-cache\nContent-type: text/html\n\n";
print "<TITLE>PSUpload Demonstration Upload Program - Debug Mode</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\" TEXT=\"#330066\" LINK=\"#336666\" ALINK=\"#336666\" VLINK=\"#336666\" BGCOLOR=\"#FFFFFF\"><FONT SIZE=\"2\" FACE=\"verdana, arial, helvetica\">\n";
print "<CENTER><B><H2>Charity Ware's PSUpload Program</H2></B><BR><BR><TABLE BORDER=0><TR><TD COLSPAN=2><FONT SIZE=\"2\" FACE=\"verdana, arial, helvetica\">\n";
print "<DL><DT><B>Your web root directory appears to be located at:</B><DD>$ENV{'DOCUMENT_ROOT'}<BR><BR><DT><B>You specified directory for storing the uploads is:</B><DD>$Data<BR><BR><DT><B>Your specified directory...</B><DD>\n";
if(-d $Data) {
print "...appears to be a valid directory.<BR><BR>Make sure this \$Data directory is CHMOD 777.\n";
} else {
print "...does not appear to be a valid directory.<BR><BR>\n";
unless($Data =~ /^$ENV{'DOCUMENT_ROOT'}/) {
print "The value you specified in the \$Data variable is incorrect. Please<BR>correct your \$Data variable and run debug again.<BR><BR>\n";
}
}
if($Data =~ /\/$/) {
print "<FONT COLOR=\"#FF0000\">NOTE: Your variable \$Data ends with a trailing slash. Please<BR>remove this trailing slash, upload the program again<BR>and run debug once more to see if you have a valid directory.</FONT><BR><BR>\n";
}
print "</DL><BR><BR></FONT></TD></TR><TR><TD WIDTH=\"50%\" VALIGN=\"TOP\"><FONT SIZE=\"2\" FACE=\"verdana, arial, helvetica\"><B>OS:</B><BR>$^O<BR><BR><B>Perl:</B><BR>$]</FONT></TD><TD VALIGN=\"TOP\"><FONT SIZE=\"2\" FACE=\"verdana, arial, helvetica\"><B>Installed:</B><BR>"; my @inst = split(/\//, $ENV{'SERVER_SOFTWARE'}); print join("<BR>", @inst); print"</FONT></TD></TR></TABLE><BR><BR><BR><BR><A HREF=\"http://www.charityware.ws/\"></A></CENTER><BR><BR></FONT></BODY></HTML>\n";
} else {
use CGI;
$max_num_files &#0124; &#0124;= 1;
$Data &#0124; &#0124;= $ENV{'DOCUMENT_ROOT'};
undef @bad_extensions if @good_extensions;
for(my $a = 1; $a <= $max_num_files; $a++) {
my $req = new CGI;
if($req->param("FILE$a")) {
my $file = $req->param("FILE$a");
my $filename = $file;
$filename =~ s/^.*(\\

axleclarkeuk
Paranoid (IV) Inmate

From: Swansea, Wales, UK
Insane since: Aug 2001

posted posted 09-24-2001 22:33

Ummmmm thats scripts dont look too good posted here eh ? can you still read it or do you want me to post in in TXT format online ?

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 09-24-2001 22:47

Post that script in plain text (TXT) instead...

axleclarkeuk
Paranoid (IV) Inmate

From: Swansea, Wales, UK
Insane since: Aug 2001

posted posted 09-24-2001 22:56

Here ya go again

This is a script someone used from some other source for a client, but i am trying to sort it out ( with your help ).

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 09-25-2001 19:48

I went to script's web site ( http://www.perlservices.net/ ) in order to download complete script and I've read this bit of text:

--- start copy/paste ---
Upgrade to 2.1, May 28th, 2001
Some users reported the problem with files being uploaded form Windows systems. Since the Windows O/S supports file names with spaces in them, files uploaded with spaces would be stored on a UNIX server but would be 0 bytes in length. PSUpload has been modified to account for this situation.
--- end copy/paste ---

So, apparently you should download new version of the script ( http://www.perlservices.net/en/download/dl_count.cgi?1 )...

axleclarkeuk
Paranoid (IV) Inmate

From: Swansea, Wales, UK
Insane since: Aug 2001

posted posted 09-26-2001 00:15

You are a STAR !!! Thanks for taking the time to look into this, i was rading through the site myself yesterday, lol why the hell did i not notice this ?

Thanks again !

« BackwardsOnwards »

Show Forum Drop Down Menu