Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Upload file

Expand Messages
  • Arun Pandey
    cool !! Fro the sake of curiosity ... what were the issues with the webserver ? ... From: Hetal Modi To:
    Message 1 of 11 , Jul 28, 2006
    • 0 Attachment
      cool !!
      Fro the sake of curiosity ... what were the issues with the webserver ?
      ----- Original Message -----
      From: "Hetal Modi" <hetalkrishna@...>
      To: <perl-beginner@yahoogroups.com>
      Sent: Saturday, July 29, 2006 12:05 AM
      Subject: Re: [PBML] Upload file


      Thank you Arun for the help.

      There were some issues with web server. I could change them and my script
      is running fine now.

      Regards,
      -Hetal


      Arun Pandey <arunp@...> wrote:
      Hey Hetal,
      I didn't get a chance to simulate your problem at my end. Aplogies.
      Your HTML file looks alright to me. There are a few things which I would
      like to point out in your CGI script.

      1.) You are not closing the output file, although this shouldn't be much of
      a problem, but buffering related issues at times can cause weird issues like
      an em pty file or so.
      2.) Although method param should give you a file handle, please try using
      the upload method and check whether you have a valid file handle

      Please let me know if the above helps.

      -Arun

      ----- Original Message -----
      From: "Hetal Modi" <hetalkrishna@...>
      To: <perl-beginner@yahoogroups.com>
      Sent: Tuesday, July 25, 2006 9:31 PM
      Subject: Re: [PBML] Upload file

      Here is the Html file and CGI script I have used for uploading PDF files.
      ----------------------------------------------------------
      --------------------
      Html file -
      <html>
      <head><title>uploading</title></head>
      <body>
      <FORM ENCTYPE="multipart/form-data" ACTION="upload.cgi" METHOD="POST">
      Please choose directory to upload to:<br>
      <p>
      Please select a file to upload: <BR>
      <INPUT TYPE="FILE" NAME="file">
      <p>
      <INPUT TYPE="submit">
      </FORM>
      </body>
      </html>

      ----------------------------------------------------------
      -----------------

      Upload CGI Script
      #!/usr/bin/perl -w
      use strict;
      use CGI;
      my $cgi = new CGI;
      my $uploaddir = "/home/user/upload";
      my $file = $cgi->param('file');
      $file=~m/^.*(\\|\/)(.*)/;
      my $name = $2;
      open(LOCAL, ">$uploaddir/$name") or die "no file";
      binmode $file;
      binmode LOCAL;
      while(<$file>)
      {
      print LOCAL $_;
      }
      print "Content-type:text/html\n\n";
      print "<HTML><HEAD><TITLE>together.cgi results</TITLE></HEAD>";
      print "<body>";
      print "$file has been successfully uploaded... thank you.\n";
      print "</body>";
      print "</html>";

      ----------------------------------------------------------
      ----------

      Thanks,

      -Hetal
      Arun Pandey <arunp@...> wrote:
      w.r.t to your current problem, it shouldn't matter whether your
      browser is
      running on a windows machine or a linux machine. As long as your posting the
      data(multipart) to your CGI script, CGI.pm should be bale to give you a file
      handle. Can you send the relevant script/html wherein the user uploads the
      file ?
      ----- Original Message -----
      From: "Hetal Modi" <hetalkrishna@...>
      To: <perl-beginner@yahoogroups.com>
      Sent: Tuesday, July 25, 2006 8:46 PM
      Subject: Re: [PBML] Upload file

      Hello Arun,

      Thanks for the reply. I have set that attribute. But, I am not sure why it
      is not working. This script is working in windows(when application is also
      in windows and i m using that in windows), but not working in linux.

      Actually, my application is running in linux, but I can open that
      application in windows. So, I try to upload file from windows to linux local
      directory.

      Regards,
      -Hetal

      Arun Pandey <arunp@...> wrote:
      Hey Hetal,
      looks like there you havne't set the required attributes in the form tag.
      make sure the form tag (the one where user is actually uploading the file)
      has the following

      ENCTYPE="multipart/form-data"

      The absence of this attribute makes the browser send only the file name
      isntead of the data stream.

      Thanks
      Arun
      ----- Original Message -----
      From: "Hetal Modi" <hetalkrishna@...>
      To: "perl" <perl-beginner@yahoogroups.com>
      Sent: Sunday, July 23, 2006 8:02 AM
      Subject: [PBML] Upload file

      > Hi,
      > I want to upload a file using browser and save it in a local directory
      in linux.
      > I wrote the following code for that. I am getting a 'no file found'
      error.
      > When I printed $file, I see that it is taking only the file name and not
      the entire path.
      >
      > Could anybody please let me know what I should do to get the entire
      path.
      >
      > Thanks,
      > -Hetal
      >
      >
      >
      > #!/usr/bin/perl -w
      > use strict;
      > use CGI;
      > use CGI::Carp qw(fatalsToBrowser);
      > print "Content-type:text/html\n\n";
      > print "<HTML><HEAD><TITLE>together.cgi results</TITLE></HEAD>";
      > print "<body>";
      > my $cgi = new CGI;
      > my $uploaddir = "/home/user/uploaddir";
      > my $file = $cgi->param("file");
      > print "\n\nfile = $file\n\n";
      > my $upload_file = $cgi->upload("file");
      > open(LOCAL, ">$uploaddir/$file") or die "no file";
      > while(<$upload_file>)
      > {
      > print LOCAL $_;
      >
      > }
      > print "$file has been successfully uploaded... thank you.\n";
      > print "</body>";
      > print "</html>";
      >
      >
      > ---------------------------------
      > Do you Yahoo!?
      > Next-gen email? Have it all with the all-new Yahoo! Mail Beta.
      >
      > [Non-text portions of this message have been removed]
      >
      >
      >
      >
      > Unsubscribing info is here:
      http://help.yahoo.com/help/us/groups/groups-32.html
      > Yahoo! Groups Links
      >
      >
      >
      >
      >
      >
      >

      ---------------------------------
      Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+
      countries) for 2ยข/min or less.

      [Non-text portions of this message have been removed]

      Unsubscribing info is here:
      http://help.yahoo.com/help/us/groups/groups-32.html
      Yahoo! Groups Links

      ---------------------------------
      How low will we go? Check out Yahoo! Messenger's low PC-to-Phone call
      rates.

      [Non-text portions of this message have been removed]

      Unsubscribing info is here:
      http://help.yahoo.com/help/us/groups/groups-32.html
      Yahoo! Groups Links






      ---------------------------------
      Do you Yahoo!?
      Everyone is raving about the all-new Yahoo! Mail Beta.

      [Non-text portions of this message have been removed]



      Unsubscribing info is here:
      http://help.yahoo.com/help/us/groups/groups-32.html
      Yahoo! Groups Links
    Your message has been successfully submitted and would be delivered to recipients shortly.