Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 9th, 2001, 11:40 PM
crupp crupp is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2001
Posts: 3 crupp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy HTML file upload and CGI module

Hi all,

i have searched the forums but didn't find an answer for my problem...

i have a HTML form where the user can upload a file.

input type=file name=localfile value="*.*"

but when i try to get the data in the CGI script the filehandle is always undefined:

my $fh=$cgi->upload('localfile');
if (!$fh) {
return 'Error while reading data.';
}

My form is 'enctype="multipart/form-data"', even $cgi->Dump() shows that localfile is undefined, although i can see that the browser is uploading the data. I also tried $cgi->param('localfile') but it returned undef too...

What am i doing wrong?
Chris.

Reply With Quote
  #2  
Old September 10th, 2001, 06:58 AM
Acid Reign Acid Reign is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Posts: 190 Acid Reign User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 57 m 52 sec
Reputation Power: 8
Send a message via ICQ to Acid Reign
According to a book i have on my lap (O'Reilly CGI Programming) if you have a form like this:

(form already started)
Code:
<P>Please choose a file to upload
<INPUT TYPE=FILE NAME="file">
<P>Please enter the name of the file
<INPUT TYPE=FILE NAME="filename">


then you can get the file handle for the temp. file where it is stored by doing this:

Code:
my $file = $q->param( "file" );
my $fh = $q->upload( $file );

Reply With Quote
  #3  
Old September 10th, 2001, 01:38 PM
crupp crupp is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2001
Posts: 3 crupp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
No, this does not work:

in my form:
<input type="file" name="localfile" value="*.*">

in the script:
my $fn=$cgi->param('localfile');
if (!$fn) {
return 'No filename - Error while reading data.';
}
$fh=$cgi->upload($fn);
if (!$fh) {
return 'No filehandle - Error while reading data.';
}

The filename is always undefined! The error must be somewhere else but i can't find it

Reply With Quote
  #4  
Old September 10th, 2001, 05:40 PM
Acid Reign Acid Reign is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Posts: 190 Acid Reign User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 57 m 52 sec
Reputation Power: 8
Send a message via ICQ to Acid Reign
Couple of things i would try then (being too lazy to try it myself :P )

Try change the name of param. that the file is uploaded under (in other words change 'localfile' to 'lofile' )

Put $fn as some string (actually in the script) and comment out the upload line. If it still doesn't work, something is then wrong with your programming.

Expand the (!$fn) to ($fn eq undef). Make things as uncomplicated as possible, using no fancy shortcuts.

Failing that, copy and paste it all to another file and save it (it has fixed some of my script problems!!)

Reply With Quote
  #5  
Old September 11th, 2001, 12:18 AM
crupp crupp is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2001
Posts: 3 crupp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi Acid Reign,

thanks for your nice help; i just found my problem...

The CGI object was created in another file, by chance i saw that HTML uploads were disabled... ($CGI:ISABLE_UPLOADS=1)

arghllll!!


Chris

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > HTML file upload and CGI module


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT