iPowerWeb Hosting
 
Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read Web Directory

Go Back   Webmaster Forum > Designing and Developing Websites > Programming > Perl

Perl Discussions and help on Perl scripting.

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 04-08-2007, 01:42 AM
technoguy technoguy is offline
WMG Citizen
 
Join Date: Mar 2007
Posts: 436
iTrader: (0)
technoguy is on a distinguished road
Default Uploading file

How can I upload file using perl? I want to upload it to the folder images and want to rename it whie uploading. Anyone have any idea about it? I have made form using dreamweaver by using input type = file and submit button.

Thanks
Reply With Quote
Sponsored Links
Register and sign in to hide this ad block

  #2 (permalink)  
Old 06-04-2008, 02:42 PM
shiva6480 shiva6480 is offline
WMG Newcomer
 
Join Date: Jun 2008
Posts: 2
iTrader: (0)
shiva6480 is on a distinguished road
Thumbs up

Quote:
Originally Posted by technoguy View Post
How can I upload file using perl? I want to upload it to the folder images and want to rename it whie uploading. Anyone have any idea about it? I have made form using dreamweaver by using input type = file and submit button.

Thanks
Hi,
You can upload file using perl's CGI module. there are two functions available in CGI module, those are param('name') and upload('name') which will take input name in the form as argument and returns file name which you selected to upload. this is used as a filehandle and you can open that file, read the content and write into the server side file. that's all....
Reply With Quote
  #3 (permalink)  
Old 07-07-2008, 09:04 PM
natastia's Avatar
natastia natastia is offline
WMG Newcomer
 
Join Date: Jul 2008
Location: Antwerp
Posts: 3
iTrader: (0)
natastia is on a distinguished road
Default uploas

Well make a HTML page with the following code in body:

Adjust URLsite with your sites domain.

Code:
<form action="URLsite/upload.cgi" method="post"  
enctype="multipart/form-data">
<p>file location:<input type="file" name="file" /></p>
<p><center><input type="submit" name="submit" value="Upload!"/></p>
</form>
make cgi or perl script with the following code

PHP Code:
#!/usr/bin/perl -wT 

use strict
use 
CGI
use 
CGI::Carp qw fatalsToBrowser ); 
use 
File::Basename;
use 
CGI 'param';

::
POST_MAX 1024 5000;

my  "a-zA-Z0-9_.-";

#the place where your file shall be saved on the server
my  "upload";


my  = new CGI
my  = ("file");


####here we will check the filename to prevent abusing##########
####Not necessary for actual uploading but to protect the server###



if ( ! ) 

print  ( ); 
print 
"There's a problem with uploading your music, make sure that the file is less then 5mb."
exit; 
}

my ( , ,  ) = fileparse ( , '..*' ); 
 =  . ;

 =~ 
tr/ /_/; 
 =~ 
s/[^]//g;

if (  =~ /^([]+)$/ ) 

  = $
1

else 

 die 
"Filename contains invalid characters"
}

###actual uploading#####

my  = ("file");

open UPLOADFILE">/" ) or die "$!"
binmode UPLOADFILE

while ( <> ) 

 print 
UPLOADFILE


close UPLOADFILE
Reply With Quote
  #4 (permalink)  
Old 07-07-2008, 09:06 PM
natastia's Avatar
natastia natastia is offline
WMG Newcomer
 
Join Date: Jul 2008
Location: Antwerp
Posts: 3
iTrader: (0)
natastia is on a distinguished road
Default variables gone

Damn this forum blocked my variables in the perl code! How can i write the perl code without variables ($) getting removed?
Reply With Quote
Reply


Thread Tools
Display Modes

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

All times are GMT. The time now is 06:38 PM.



Freelance Web Designers
Work At Home Forum
Ad Marketplace
Online Deals and Bargains
midPhase Web Hosting - $7.95/month - 500 GB B/W! Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0