I want more information for me to be able to help you.

Please give the exact error.

-Girish

On Tue, Nov 10, 2009 at 12:14 PM, Rajesh kumar
<[email protected]> wrote:
> I wrote a simple perl cgi in unix to upload a file in linux server and it
> worked and when i tried the code in windows server with some little
> modification regarding to work on windows it failed.
> I tried some googling and i dint find any code related to upload on windows
> server. so i need some help in resolving this
>
> The code is below
>
> FILE: UPLOAD.PL
>
> use CGI;
> use CGI::Carp qw ( fatalsToBrowser );
> use File::Basename;
> $safe_filename_characters = "a-zA-Z0-9_.-";
> $upload_dir = "c:/";
> $query = new CGI;
> foreach $i (@values) {
> ($varname, $data) = split(/=/, $i);
> $FORM{$varname} = $data;
> }
> $filename = $FORM{'file_upload'};
> $name = $FORM{'name'};
> if ( !$filename )
> {
> $filename = 'f:/input.txt'
> }
>
> 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("file_upload"); # i Think the script
> produces error here
>
> open ( UPLOADFILE, ">$upload_dir/$filename" ) or die "$!";
> binmode UPLOADFILE;
>
> while ( <$upload_filehandle> )
> {
>  print UPLOADFILE;
> }
>
> close UPLOADFILE;
>
> print $query->header ( );
> print $query->start_html('upload');
> print $name." file Uploaded";
> print $query->end_html();
>
> and to reference my html page is
>
> FILE:UPLOAD.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>File Upload</title>
>  </head>
>  <body>
>   <form action="/cgi-bin/upload.cgi" method="post"
> enctype="multipart/form-data">
>     <p>Photo to Upload: <input type="file" name="file_upload" /></p>
>     <p>Name: <input type="text" name="name" /></p>
>     <p><input type="submit" name="Submit" value="Submit Form" /></p>
>   </form>
>  </body>
> </html>
>
> --
> Regards
> Rajesh Kumar R.K
> www.rkrajeshkumar.in
> _______________________________________________
> To unsubscribe, email [email protected] with
> "unsubscribe <password> <address>"
> in the subject or body of the message.
> http://www.ae.iitm.ac.in/mailman/listinfo/ilugc
>



-- 
Gayatri Hitech
web: http://gayatri-hitech.com

SpamCheetah Spam filter:
http://spam-cheetah.com
_______________________________________________
To unsubscribe, email [email protected] with
"unsubscribe <password> <address>"
in the subject or body of the message.
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc

Reply via email to