SitePoint Sponsor

User Tag List

Page 1 of 8 12345 ... LastLast
Results 1 to 25 of 181
  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
    Cynthia Salzman
    SitePoint Community Guest
    I read your instructions on how to allow users to upload files to a webserver. I would like to do something like this but not post to a webserver, instead, I wanted to have a form which contains a browse button so a user can attach a picture and upon submitting the form, send their photo to an e-mail. I don't want the picture stored anywhere just sent. I'm currently using CDONTS for my webmail - do you have any suggestions on how to do this? I've search Google and anything that comes close to this is either .Net (over my head) or costs $$$ in a package that I would need to buy. :-(

    Thanks!

  3. #3
    pieter
    SitePoint Community Guest
    @cynthia : easy, you upload the file to the browser, store it, then send an email from the script and delete the pic again.

  4. #4
    Daniel
    SitePoint Community Guest
    I've installed the script and it seems to work but for one small problem, it doesn't place the file in the directory. Thus no photo available to show.

  5. #5
    SitePoint Member
    Join Date
    Aug 2004
    Location
    Uttoxeter
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    Quote Originally Posted by pieter
    @cynthia : easy, you upload the file to the browser, store it, then send an email from the script and delete the pic again.
    Okay. That looks like a good solution. Before I go away and invest several hours in figuring it out - is there a fairly simple way to do this (starting from Matt's excellent script that works a treat)?

    Steve

  6. #6
    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?

  7. #7
    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

  8. #8
    Ali
    SitePoint Community Guest
    Hi, How about uploading file2.pl on file1.pl
    should the user click on button "report"
    my email is alifouad@ambros.plus.com

    many thanks

  9. #9
    Leif
    SitePoint Community Guest
    You should use read() instead of <> when copying the file so your script doesn't crash if you have a single line thats 100 MB long.

  10. #10
    Brad
    SitePoint Community Guest
    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?? email me at vonoven1@cox.net if you can help me.

  11. #11
    Ron
    SitePoint Community Guest
    Is this safe for me to use on a shared server or will my ISP flip out....?

  12. #12
    SitePoint Member
    Join Date
    Dec 2004
    Location
    Pittsburgh
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry for my ignorance, but is it possible for me to use this script on a shared server, or will my ISP freak out about security?

    Thanks

    Ron

  13. #13
    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

  14. #14
    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

  15. #15
    SitePoint Member
    Join Date
    Dec 2004
    Location
    dallas, tx
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, I wrote your script to upload files but it does not seem to work correctly and I've done everything correctly. Can you please check it out and notify if you see any mistakes? Thanks! Joe

    #!/usr/bin/perl -w
    use CGI;

    $upload_dir = "http://www.jlreyes.com/cgi-bin/upload";

    $query = new CGI;

    $filename = $query->param("photo");
    $email_address = $query->param("email_address");
    $filename =~ s/.*[\/\\](.*)/$1/;
    $upload_filehandle = $query->upload("photo");

    open UPLOADFILE, ">$upload_dir/$filename";

    while ( <$upload_filehandle> )
    {
    print UPLOADFILE;
    }

    close UPLOADFILE;

    print $query->header ( );
    print <<END_HTML;

    <HTML>
    <HEAD>
    <TITLE>Thanks!</TITLE>
    </HEAD>

    <BODY>

    <P>Thanks for uploading your photo!</P>
    <P>Your email address: $email_address</P>
    <P>Your photo:</P>
    <img src="http://www.jlreyes.com/cgi-bin/upload/$filename" border="0">

    </BODY>
    </HTML>


    The script is located at: http://www.jlreyes.com/temp/upload2004.html

    my email is: jreyes@aboutreal.com

  16. #16
    Daniel
    SitePoint Community Guest
    When I run this I get the following error: Software error:
    Can't locate object method "new" via package "CGI" at upload.cgi line 8.

    I don't understand what this means. Any help? I'm obviously brand new at this.


    #!/usr/bin/perl -s

    use CGI::Carp qw/fatalsToBrowser/;


    $upload_dir="/home/wmdband/www/upload";

    $query = new CGI;

    $filename = $query->param("photo");

    $filename =~ s/.*[\/\\](.*)/$1/;

    $upload_filehandle = $query->upload("photo");

    open UPLOADFILE, ">$upload_dir/$filename";

    binmode UPLOADFILE;

    while ( <$upload_filehandle> )
    {
    print UPLOADFILE;
    }

    close UPLOADFILE;

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

    It sounds like the machine you're running the Perl script on doesn't have the CGI.pm library installed:

    http://stein.cshl.org/WWW/software/CGI/

    Also make sure you have "use CGI;" at the top of your script.

    Matt

  18. #18
    Ajay R
    SitePoint Community Guest
    Hello,

    I copy-pasted the code exactly as per your instructions (after changing the paths), but I seem to be facing a problem with the upload. The uploaded file is getting created alright (with the correct filename) however its file size is always zero. Could you please help?

  19. #19
    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

  20. #20
    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?

  21. #21
    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

  22. #22
    Soumyabrata Ghosh
    SitePoint Community Guest
    when i run the example script,it returns:-
    ____________________________________________
    Server error!

    The server encountered an internal error and was unable to complete your request.

    Error message:
    Premature end of script headers: upload.cgi

    If you think this is a server error, please contact the webmaster.
    Error 500
    localhost
    Apache/2.0.47 (Fedora)
    ____________________________________________

    do u have any solution?
    _

  23. #23
    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

  24. #24
    Ronny
    SitePoint Community Guest
    hi there. very helpful guide thanks. but how would i go about modifying it so that the uploaded files are emailed to me automatically, instead of being stored on my server?

    thanks.
    Ronny.

  25. #25
    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


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
  •