SitePoint Sponsor

User Tag List

Page 1 of 3 123 LastLast
Results 1 to 25 of 181

Hybrid View

  1. #1
    ********* Articles ArticleBot's Avatar
    Join Date
    Apr 2001
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Article Discussion

    This is an article discussion thread for discussing the SitePoint article, "Uploading Files Using CGI and Perl"

  2. #2
    SitePoint Zealot
    Join Date
    Jan 2003
    Posts
    169
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does this script allows for large files, files greater than 2MB?

  3. #3
    SitePoint Member
    Join Date
    Aug 2004
    Location
    Uttoxeter
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Lind
    Does this script allows for large files, files greater than 2MB?
    Hi.

    Yes, it seems to. For my application it probably needs to.

    S

  4. #4
    SitePoint Zealot elated's Avatar
    Join Date
    Dec 2004
    Location
    Sydney, Australia
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Ron,

    I'm the author of this article. You should be OK running this script on a shared server, but if you're concerned, then talk to your ISP first before using it.

    Matt

  5. #5
    SitePoint Zealot elated's Avatar
    Join Date
    Dec 2004
    Location
    Sydney, Australia
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Brad,

    I am getting an error! I think my absolute path for $upload_dir is wrong. I put #!/usr/bin/perl -w
    $upload_dir = "/upload";
    Because I just created a folder called upload in the root. Is this right??
    Yes, it looks like your $upload_dir is probably incorrect. It should include the absolute path to your web site's document root folder, followed by "/upload". For example, it might be something like:

    Code:
    $upload_dir = "/home/sites/abc123/public_html/upload";
    If you're not sure of your web site's absolute path, ask your hosting provider.

    Hope that helps!
    Matt

  6. #6
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by elated
    If you're not sure of your web site's absolute path, ask your hosting provider.
    Would this program work as well?

    Code:
    #!/usr/bin/perl
    
    use Cwd;
    $dir = cwd;
    
    print "content-type: text/html\n\n";
    print $dir;

  7. #7
    SitePoint Zealot elated's Avatar
    Join Date
    Dec 2004
    Location
    Sydney, Australia
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sounds like you have some kind of file/directory permission problem. Maybe your hosting company doesn't allow your scripts to write to /tmp?

    Matt

  8. #8
    SitePoint Member etech2000's Avatar
    Join Date
    Jan 2005
    Location
    Burlington, MA
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Error using upload

    Hi,

    I'm getting this error using Matt's upload.cgi and file_upload.html

    Not Found
    The requested URL /upload/upload.cgi was not found on this server.

    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
    Apache/1.3.31 Server at gardening101.org Port 80

    Has anyone run into this problem and is there a solution?

  9. #9
    SitePoint Zealot elated's Avatar
    Join Date
    Dec 2004
    Location
    Sydney, Australia
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by etech2000
    Hi,

    I'm getting this error using Matt's upload.cgi and file_upload.html

    Not Found
    The requested URL /upload/upload.cgi was not found on this server.

    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
    Apache/1.3.31 Server at gardening101.org Port 80

    Has anyone run into this problem and is there a solution?
    Assuming you uploaded the file to your cgi-bin folder, the you should probably be accessing it with a URL such as:

    http://www.example.com/cgi-bin/upload.cgi

    Not:

    http://www.example.com/upload/upload.cgi

    Does that help?

    Matt

  10. #10
    SitePoint Zealot elated's Avatar
    Join Date
    Dec 2004
    Location
    Sydney, Australia
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have an error in your script or in your server config. Look in your web server's error log for the exact error message. Alternatively run the script from the command line (either on your server if possible, or on your local PC with Perl installed) to debug.

    Matt

  11. #11
    SitePoint Zealot elated's Avatar
    Join Date
    Dec 2004
    Location
    Sydney, Australia
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ronny,

    Check out the MIME-tools modules - they let you create emails, attach files (e.g. images) to them and send them.

    Cheers,
    Matt

  12. #12
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey, I'm having the same problem as someone who posted earlier. I got the script to work but when I upload files the contents show up empty. One difference is I'm using Windows (yeah I know I wish I wasn't). And I'm hosting it on a machine myself so I have full access to apache. Any ideas? Thanks in advance.

  13. #13
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Tainting error

    Great article!

    I do have two issues thus far though maybe someone can help me out with.
    The first issue occurs with the script ran as is, only changing the directory information. The file uploads into the specified directory but throws an internal server error stating that the file was not found.

    The second issue is running it -T where it throws a independency error. I get why it would do that but I am concerned about potential security risks involved not running the file in taint mode. I'm kind of wondering if I am being paranoid or if it is wise to untaint that data so it will run -T.

    Any thoughts, information, links, etc. will be extremely helpful and much appreciated!

    -Tina

  14. #14
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up One down!

    Fixed part one by removing the leading spaces from the code.

  15. #15
    SitePoint Zealot elated's Avatar
    Join Date
    Dec 2004
    Location
    Sydney, Australia
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by aezarien
    The second issue is running it -T where it throws a independency error. I get why it would do that but I am concerned about potential security risks involved not running the file in taint mode. I'm kind of wondering if I am being paranoid or if it is wise to untaint that data so it will run -T.
    -Tina
    I think it's probably failing the taint checking on the filename. If you replace:

    Code:
    $filename =~ s/.*[\/\\](.*)/$1/;
    with something like the more thorough:

    Code:
    $filename =~ /(\w+[\.\w]*)$/ or die ( "Filename was not in a recognized format." );
    $filename = $1;
    ...then that should untaint the filename (hopefully!).

    Cheers,
    Matt

  16. #16
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Spot on! Works like a charm. Thanks so much.

  17. #17
    SitePoint Zealot elated's Avatar
    Join Date
    Dec 2004
    Location
    Sydney, Australia
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lei,

    Your web server hasn't been set up properly to run CGI scripts. It's just serving the upload.cgi file as if it's a plain text file.

    You need to tell your web server that it should treat files ending in .cgi as Perl scripts and execute them, rather than serve them as files.

    Hope that helps

    Cheers,
    Matt

  18. #18
    SitePoint Zealot elated's Avatar
    Join Date
    Dec 2004
    Location
    Sydney, Australia
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Jim,

    You can make your script executable using your FTP program. There will usually be an option to "set permissions on" or "chmod" the uploaded file.

    As an MP3 is a file just like an image, you should be able to use the upload script in the tutorial to do what you need.

    Matt

  19. #19
    SitePoint Zealot elated's Avatar
    Join Date
    Dec 2004
    Location
    Sydney, Australia
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you include the " binmode UPLOADFILE; " line as described in the article? If so then you possibly have some kind of permissions problem. Make sure that the web server user is allowed to create and modify files inside your upload folder.

    Matt

  20. #20
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried adding that line and it had no impact on this problem. I'm not too sure if the permissions are set correctly.

    <Directory "C:/MATLAB701/toolbox/webserver/psws">
    AllowOverride None
    Options Indexes ExecCGI
    </Directory>

    now the actual directory I have the file uploaded to is in the path
    C:/MATLAB701/toolbox/webserver/psws/upload.

    Do the permissions get applied to all subfolders?
    Also I got rid of the "AllowOverride None" because I found out that defaults are given to folders without specific permissions.

    Thanks...

  21. #21
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just noticed something interesting...Whenever I upload a file the temporary file gets written in the documentroot directory. If you change its extension to match the file you upload it turns out to be the complete file, so that means the script does properly upload the file, it just doesnt copy it to my upload folder within documentroot. Any ideas?

  22. #22
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, so I figured it out it was this line:

    $query = new CGI->new;

    I took out ->new and it worked.

  23. #23
    SitePoint Zealot elated's Avatar
    Join Date
    Dec 2004
    Location
    Sydney, Australia
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could be a permissions problem maybe? Make sure the webserver user has permission to create files in your "upload" directory. Also check that the path to the "upload" directory as specified in your script is correct.

    Matt

  24. #24
    SitePoint Zealot elated's Avatar
    Join Date
    Dec 2004
    Location
    Sydney, Australia
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Tom

    Your $upload_dir should probably include the path to your web site from the volume root, eg:

    $upload_dir = "/var/www/html/temp/"

    Make sure the "temp" folder is writable by your webserver user too.

    Matt

  25. #25
    SitePoint Zealot elated's Avatar
    Join Date
    Dec 2004
    Location
    Sydney, Australia
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    AFAIK IE doesn't have an upload file size limit.

    To set a limit server-side, use CGI.pm's $CGI::POST_MAX variable. See http://search.cpan.org/~lds/CGI.pm-3...ervice_Attacks for details. I believe the default behaviour is to have no limit.

    Cheers
    Matt


Bookmarks

Posting Permissions

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