Results 1 to 7 of 7

Thread: CGI file upload script problem

  1. #1

    CGI file upload script problem

    I'm trying to use this cgi script (didn't attach html with forms...):

    Code:
    #!/bin/sh
    use strict;
    use CGI;
    use CGI::Carp qw ( fatalsToBrowser );
    use File::Basename;
    
         my $upload_filehandle = $query->upload("userfile");
         $filename = $1; 
         open ( UPLOADFILE, ">/upload/$filename" ) or die "$!";
         binmode UPLOADFILE;
         
         while ( <$upload_filehandle> )
         {
          print UPLOADFILE;
          }
          
          close UPLOADFILE;
    The problem is - nothing happens. I'm using lighttpd with mod-cgi (tryed fastcgi, but couldn't handle .cgi files).

    I get this error.log entry when clicking "upload" button:


    2009-08-24 23:17:51: (mod_cgi.c.1118) write() failed due to: Broken pipe
    Any ideas?

  2. #2
    Assuming you use lighttpd, I could not get it to work either.
    I use the package haserl now (http://haserl.sourceforge.net/) for my upload page.

  3. #3
    good idea to use haserl.

    But I get response "file uploads not allowed".

    Then I echoed the HASERL_UPLOAD_LIMIT and it returns 0.

    So I guess the first line of the script is not parsed correctly?

    Code:
    #!/opt/bin/haserl --upload-limit=4096 --upload-dir="/ul"
     content-type: text/html
    
     <html><body>
    <% echo $HASERL_UPLOAD_LIMIT %>     #returns 0
    
    <% echo $HASERL_UPLOAD_DIR %>        #returns /tmp
    
    <form action="<% echo -n $SCRIPT_NAME %>" method=POST enctype="multipart/form-data" >
     <input type=file name=uploadfile>
     <input type=submit value=GO>
     <br>
     <% if test -n "$FORM_uploadfile"; then %>
             <p>
             You uploaded a file named <b><% echo -n $FORM_uploadfile_name %></b>, and it was
             temporarily stored on the server as <i><% echo $FORM_uploadfile %></i>.  The
             file was <% cat $FORM_uploadfile | wc -c %> bytes long.</p>
             <% rm -f $FORM_uploadfile %><p>Don.t worry, the file has just been deleted
             from the web server.</p>
     <% else %>
             You haven.t uploaded a file yet.
     <% fi %>
     </form>
     </body></html>

  4. #4
    I have --upload-target instead of --upload-dir:

    Code:
    #!/opt/bin/haserl --upload-limit=4096 --upload-target=/tmp

  5. #5
    Something else must be wrong. Now I'm pretty sure it's lighttpd configuration.

    Command line parameter (upload-limit) is just not passed over to haserl.

    Could you perhaps show your lighttpd.conf file?

    I've found somewhere same problem, but the solution was to use httpd. I don't want to do that.

    thanks

  6. #6
    There is nothing haserl specific in my conf file.
    For mod_cgi there is only:

    Code:
    $HTTP["url"] =~ "^/cgi-bin" { 
        cgi.assign = ( "" => "" )
    }
    Did you check that the user that runs lighttpd has write permission for the upload dir?

  7. #7
    Thank you, that was it!
    I had ....=> "/opt/bin/haserl"...

    so it didn't take arguments from the first line of the script

    i'll post instructions for the whole thing now

Similar Threads

  1. Установка rTorrent "на пальцах".
    By Archim in forum Russian Discussion - РУССКИЙ (RU)
    Replies: 857
    Last Post: 01-01-2011, 10:40
  2. Русские имена торрентов
    By Mirage-net in forum Russian Discussion - РУССКИЙ (RU)
    Replies: 110
    Last Post: 18-06-2010, 14:16
  3. BusyBox cgi Script Fehlerbehandlung
    By WLAN-Fan in forum German Discussion - Deutsch (DE)
    Replies: 0
    Last Post: 03-06-2008, 16:11
  4. Error installing IPKG
    By Cyb in forum WL-500g Q&A
    Replies: 2
    Last Post: 09-02-2007, 09:18

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •