Thread: Uploading file
View Single Post
  #3 (permalink)  
Old 07-07-2008, 10: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
Sponsored Links
Register and sign in to hide this ad block