It is currently Thu May 24, 2018 11:34 am


All times are UTC


Forum rules


Please click here to view the forum rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Perl upload image script trouble
PostPosted: Mon May 18, 2009 8:42 pm 
Noobie
Noobie

Joined: Mon May 18, 2009 7:17 pm
Posts: 1
Hello can anyone help me here?
When i first tried to upload an image using a form i received the error;
"cgi open of tmpfile :read only file system"
I added the line;
$CGITempFile::TMPDIRECTORY = '/tmp';
after being advised from a support ticket.
I now get the error;
No such file or directory at /home/www/yourdomain/cgi-bin/upload.pl line 40.(ive marked this with two ++)
Is this fixable?

Thanks.



#!/usr/bin/perl -wT

use strict;
use CGI;
use CGI::Carp qw ( fatalsToBrowser );
use File::Basename;

$CGI::POST_MAX = 1024 * 5000;
$CGITempFile::TMPDIRECTORY = '/tmp';
my $safe_filename_characters = "a-zA-Z0-9_.-";
my $upload_dir = "/www/yourdomain/uploads";

my $query = new CGI;
my $filename = $query->param("photo");
my $email_address = $query->param("email_address");

if ( !$filename )
{
print $query->header ( );
print "There was a problem uploading your photo (try a smaller file).";
exit;
}

my ( $name, $path, $extension ) = fileparse ( $filename, '\..*' );
$filename = $name . $extension;
$filename =~ tr/ /_/;
$filename =~ s/[^$safe_filename_characters]//g;

if ( $filename =~ /^([$safe_filename_characters]+)$/ )
{
$filename = $1;
}
else
{
die "Filename contains invalid characters";
}

my $upload_filehandle = $query->upload("photo");

open ( UPLOADFILE, ">$upload_dir/$filename" ) or die "$!"; ++
binmode UPLOADFILE;

while ( <$upload_filehandle> )
{
print UPLOADFILE;
}

close UPLOADFILE;

print $query->header ( );
print <<END_HTML;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Thanks!</title>
<style type="text/css">
img {border: none;}
</style>
</head>
<body>
<p>Thanks for uploading your photo!</p>
<p>Your email address: $email_address</p>
<p>Your photo:</p>
<p><img src="/www/yourdomain/uploads/$filename" alt="Photo" /></p>
</body>
</html>
END_HTML
;

:roll:


Top
 Profile  
 
 Post subject: Wonderful...
PostPosted: Sat Jul 18, 2009 6:09 pm 
Noobie
Noobie

Joined: Sat Jul 18, 2009 4:16 pm
Posts: 2
Location: New York - USA
I had a similar upload script that suddenly quit working, (apparently as a
result of relocating 100webspace to new servers some time ago ?).

After fiddling around with things for a while I thought upload programs just
weren't going to be allowed for security reasons or something and gave
up.

I just tried adding the line suggested:


$CGITempFile::TMPDIRECTORY = '/tmp';


Other than having to reset permissions on the upload folder (not sure how
they got changed... possibly also during the move?) It worked like magic!

At first the error message changed from what was posted above to:

-------------
Forbidden
You don't have permission to access /uploads/uploadfile.jpg on this server.
-------------

Thanks for the FORUM!

BTW did the above mentioned problem ever get solved? ("No such file
or directory at...")?

I'm still working on this program. What I would like to do is have a way to
upload ~ and resize ~ photos to a standardized/specified size or sizes.

Here is part of the program that was modified: (and seems, now, to be
working again)

#!/usr/bin/perl
#
######################################
# File Upload
# By Tom...
# This program is free software you can redistribute it
# and/or modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation
# ...yada yada yada
####################################

use strict 'refs';
use CGI::Carp qw/fatalsToBrowser/;
use CGI ':cgi-lib';
use CGI ':cgi';

$CGITempFile::TMPDIRECTORY = '/tmp'; ### new line added.

%name_value = Vars;
$FILEHANDLE = param(path_to_file);

#etc...
-------------------------------

BTW... The list of available Perl Modules page at: http://perlmodules.100ws.com/

Looking for Image::Magick

The page seems to be missing: " The page cannot be displayed
The page you are looking for is currently unavailable. The Web site might be experiencing technical difficulties,..."

Note: Found Image::Magick. It appears to be available on 100WS server.
Found it using Perl Diver. Available here:

http://www.scriptsolutions.com/programs/free/perldiver/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ]  Moderators: fhmagic, KJ, Support Team, Moderators

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
100WebSpace © 2011