#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Location
    Denver, CO
    Posts
    0
    Rep Power
    0

    Angry


    I am trying to get an Excel file from a file server to a web server and I am having trouble getting the file to write/copy to a directory on the webserver. I used the UPLOAD_file() with a multipart_form and I am slecting the file but the file does not copy. I am useing the following code.


    print $cgi->start_multipart_form(
    -action=>$action,
    -name=>"formdata"
    ),"\n";
    print $cgi->filefield(-name=>"sourcefile",
    -value=>"some_local_directory",
    -size=>80
    ),"\n";


    # Second part of the script

    open (OUTFILE,"> $dest_file");
    while ($bitesread=read($sourcefile,$buffer,1024))
    {
    print OUTFILE $buffer or die "can't copy file";
    # print "info from file $buffer\n";
    }



    The OUTFILE is being created with 0 bites in it. The directory I am writting to does have the permissions for -RWXRWXRW-. For the group http://www. that is not the problem.

    Has anyone used the UPLOAD_FILE() before.
    Any thoughts would be very welcome......
  2. #2
  3. Ole` Timer
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Location
    N.W. Iowa
    Posts
    472
    Rep Power
    14
    Are you uploading this file on a UN*X or WINDOW's server?? Can you upload text files to this server?? As they may have disabled uploads in the CGI.pm($DISABLE_UPLOADS=1). What mime type does the uploadinfo($sourcefile); displays?? I am assume your using the installed CGI.pm module included with Perl,..correct

    Code:
    open (OUTFILE,"> $dest_file"); 
                             while ($bitesread=read($sourcefile,$buffer,1024)) 
                             { 
                             print OUTFILE $buffer or die "can't copy file"; 
                             # print "info from file $buffer\n"; 
                             }
    how are you assigning the $dest_file and $sourcefile??

    [Edited by mickalo on 01-30-2001 at 11:45 AM]

    Thunder Rain Internet Publishing

    Custom Programming & Database development
    Providing Personal/Business
    Internet Solutions that work!
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Location
    Denver, CO
    Posts
    0
    Rep Power
    0

    Angry


    Yes I am useing the CGI.pm that was installed with perl on a UNIX server(SUN 5.7). I will check with the administrator about the upload flag.

    Thank You
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Location
    Denver, CO
    Posts
    0
    Rep Power
    0

    Angry


    Sorry, foprgot a question you wrote.

    The $dest_file is defined to a standard name so that another script can use that file name with out change.

    The $Sourcefile is from $sourcefile=$cgi->param('from_first part_of_the_script'); (A file handle)
  8. #5
  9. Ole` Timer
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Location
    N.W. Iowa
    Posts
    472
    Rep Power
    14
    If the script isn't too long, post a copy of it here. It appears the problem maybe how your assigning the $dest_file.

    Mickalo

    Thunder Rain Internet Publishing

    Custom Programming & Database development
    Providing Personal/Business
    Internet Solutions that work!

IMN logo majestic logo threadwatch logo seochat tools logo