SitePoint Sponsor

User Tag List

Page 5 of 8 FirstFirst 12345678 LastLast
Results 101 to 125 of 181
  1. #101
    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 HELPTony
    Am having a bit of a mare trying to get this script to work :'( - I've followed everyone's advice and posts here, and have managed to get to a point where the 500 error message is saying:

    Can't find string terminator "END_HTML" anywhere before EOF at line 25

    I've read the link from R.Andom's post saying he had a fix for this error and unfortunately this does not make much sense to me!

    Can anyone explain to me what I need to do to fix this error?

    Thanks for your help,
    Tony
    Make sure there's no whitespace before the terminating END_HTML marker - the E must be the first character on the line.

    Make sure you uploaded the file in ASCII (text) mode.

    Matt

  2. #102
    amos
    SitePoint Community Guest
    I am using an opera browser and when running the upload.cgi script what happens is that i recievce the whole script printed on the browser, what am i doing wrong ?

  3. #103
    ben
    SitePoint Community Guest
    great article, but I am getting an internal server error (500). I have checked the permissions and made sure that the paths are correct and uploaded in ASCII. The file is at prettyshady.com/upload. Thanks

  4. #104
    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 amos
    I am using an opera browser and when running the upload.cgi script what happens is that i recievce the whole script printed on the browser, what am i doing wrong ?
    Your site/server (or the folder where you've uploaded the script) isn't set up to run CGI scripts, and/or you haven't set execute permission on the script.

  5. #105
    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 ben
    great article, but I am getting an internal server error (500). I have checked the permissions and made sure that the paths are correct and uploaded in ASCII. The file is at prettyshady.com/upload. Thanks
    Look in your server's error log for the actual error message, or run the script from the shell prompt to debug.

    You can find more info on troubleshooting CGI scripts in this tutorial on our site.

    Hope that helps!

    Matt

  6. #106
    taden
    SitePoint Community Guest
    How can I set an execute permission to file?

  7. #107
    SitePoint Zealot elated's Avatar
    Join Date
    Dec 2004
    Location
    Sydney, Australia
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    chmod a+x <filename>

    Also try this tutorial.

    Cheers,
    Matt

  8. #108
    SitePoint Member
    Join Date
    Mar 2006
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for the response but i have exec permissions on the script do you have another idea to the result i am getting ( amos from before )
    thanks!

  9. #109
    Steve
    SitePoint Community Guest
    Wonderful script and great writing style and explanation of things.

    few questions:
    1) How do I restrict the file size of the icture being uploaded to 120K
    2) How do I restrict file types to .jpg, .tif, .bmp

  10. #110
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I really like your tutorial but I'm getting a error when I hit the submit button.
    it says"

    Internal Server Error
    The server encountered an internal error or misconfiguration and was unable to complete your request

    I would appreciate any help I can get thank you!

  11. #111
    Neil Tustin
    SitePoint Community Guest
    Hi tsears, I changed $upload_dir = whatever; to $upload_dir = "."; for the time being. I will add code so that it makes a new folder for each user soon. Also dont forget to change your upload.cgi file permision to 755! I am not sure how secure this method is as yet, but I am going to look into it all, and may be writing a more advanced version of my own. This will include an upload file size limiter, for more info write to cgi@thelenches.co.uk, have fun!

  12. #112
    barry
    SitePoint Community Guest
    For a client on my website to have the facilty to upload 8-10 photos at once, and also for them to have password entrance so as not to create confusion with clients with same name and photo uploads.

    How can I expand on the script that you have supplied here?

    Cheers.

    netbroker

  13. #113
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thx for nice post

  14. #114
    SitePoint Member
    Join Date
    May 2006
    Location
    Bangalore,India
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    I read ur article and it helped me a lot.Right now i am facing a problem with the code.I used the code to upload the file which is not a binary file and i wrote a upload.cgi script and when i run the script i get a error- Undefined subroutine CGI::upload. Can you please suggest me a solution.

    Regards,
    Deepa

  15. #115
    shweta agrawal
    SitePoint Community Guest
    i want to store word file in mysql using perl

  16. #116
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice Work! Too bad it didn't work for my AOL website. I must have some path missing or not conforming to the AOL cgi-bin format. I uploaded the cgi script to the AOL website directory which is http://hometown.aol.com/Djosepa2z/upload.cgi.
    as instructed and named it upload.cgi and its upload_dir reads as: $upload_dir = "/hometown.aol.com/Djosepa2z/fileupload";

    I created an upload and uploaded it to the same website directory. It url is http://hometown.aol.com/Djosepha2z/upload
    I uploaded the HTML form page to the same website directory and named it fileupload and its url is http://hometown.aol.com/Djosepa2z/fileupload.htm and this is how its Form Action reads: <FORM ACTION="/cgi-bin/formupload/upload.cgi/Djosepa2z" METHOD="post" ENCTYPE="multipart/form-data">

    Something is still off. It didn't work. I rate your article as excellent! Thanks for the info.

  17. #117
    Mia Orqhed
    SitePoint Community Guest
    I did try this and it's good and easy to understand. But until now when i try to 'submit form'.. this error occured--->The page cannot be displayed
    The page you are looking for is currently unavailable. The Web site might be experiencing technical difficulties, or you may need to adjust your browser settings. I'm not sure either it's my CGI file setup wrongly. Please help.......

  18. #118
    phailure
    SitePoint Community Guest
    i followed all of it, chmoded everything correctly, madesureall of the info was correct, and it fgives me a 500 internal server error evertime i hit submit. it is borked.

  19. #119
    Bob Knob
    SitePoint Community Guest
    Everything checked and double checked but I'm not getting anything from the $query->param("photo") line. It claims there is no value for photo.

  20. #120
    Ian Anderson
    SitePoint Community Guest
    Parsing paths using regular expressions is potentially dangerous. It's much safer to use the splitpath function from the File::Spec module which can be used to extract a filename from a path when called like so:

    use File::Spec;

    ...

    # File::Spec returns volume name, path, filename - we only want filename
    (undef, undef, $filename) = File::Spec->splitpath($filename);

    If the $filename variable is only the filename itself, this call will leave it as-is.

  21. #121
    dinos
    SitePoint Community Guest
    cgi scripts have no permission to write on the document root. Any suggestions on how to make the file visible?

  22. #122
    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;

  23. #123
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bbmonkey View Post
    Hi Matt,

    I'm getting 0kb files created in the right location. I create a unique directory for a user with the permission set to 755. But when I check the error log, I see these error messages on the line where we read in the file handle:
    Code:
    while ( <$uploadfh> )
    Use of uninitialized value in <HANDLE>

    and

    readline() on unopened filehandle

    My version of CGI.pm is 3.04.

    Code:
    sub uploadFile
    {
        my $uname = shift;
        my $img_upload_dir = IMG_DIR;
    
        # 
        # upload image file
        #
        
        # get the file from the form
        my $query = new CGI;
        my $photo = $query->param("photo");
        $photo =~ s/.*[\/\\](.*)/$1/;
    
        if (defined $photo) {
    
    	# make a directory for the user
    	my $userdir = File::Spec->catdir($img_upload_dir, $uname);
    	unless (-d $userdir) {
    	    unless (mkdir($userdir, 0755)) {
    		return "Failed to create directory for user.";
    	    }
    	}
    	my $fullpath_file = File::Spec->catfile($userdir, $photo);
    	
    	# open the file and read from it and upload
    	my $uploadfh = $query->upload("photo");
    
    	open UPLOADFILE, ">$fullpath_file";
    	binmode UPLOADFILE;
    	while ( <$uploadfh> ) {
    	    print UPLOADFILE $buffer;
    	}
    	close UPLOADFILE;
        } else {
    	return "Fail";
        }
        return $photo;
    }
    Any ideas??
    The problem isnt in perl script but in HTML. Your tag FORM miss or has wrong method attribute. set method="POST" and enjoy uploading.

  24. #124
    SitePoint Wizard bronze trophy KevinR's Avatar
    Join Date
    Nov 2004
    Location
    Moon Base Alpha
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The problem isnt in perl script but in HTML. Your tag FORM miss or has wrong method attribute. set method="POST" and enjoy uploading.
    Did you note the date of bbmonkeys post?

  25. #125
    gull
    SitePoint Community Guest
    nice


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
  •