| Store | Cart

Re: File won't upload

From: fREW Schmidt <fri...@gmail.com>
Tue, 30 Sep 2008 14:54:42 -0500
As for how it fails it basically just uploads an empty file.  Everything
else seems to work fine.

-fREW






#!/usr/local/bin/perl5.004

use CGI qw(:standard);
binmode(STDIN, ":utf8");
binmode(STDOUT, ":utf8");

# print standard html header
print "HTTP/1.0 200 OK\n";
print "Content-Type: text/html; charset=UTF-8\n\n";

# get form input
$Input = CGI->new();

$Option = $Input->param("Option");

if ($Option eq "UploadNewList") {
    my $uploadHandle = $Input->upload("File");
    open ( UPLOADFILE, ">".$Input->param("File")) or die $!;
    binmode UPLOADFILE;

    my $buffer;
    while(read($uploadHandle, $buffer, 1024)) {
        print UPLOADFILE $buffer;
    }
    close ( UPLOADFILE );
} else {
    print q(<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "
http://www.w3.org/TR/html4/strict.dtd">
    <html><head><title>Uploader</title></head><body>
    <form method="post" name="input" action="sores.plx">
    <input name="Option" value="UploadNewList" type="hidden" />
    File Name: <input name="File" size="30" type="file" />
    <input type="submit" value="Submit" />
    </form>
    </body></html>
    );
}
exit;




On Tue, Sep 30, 2008 at 2:53 PM, fREW Schmidt <fri...@gmail.com> wrote:

> Sorry about that.  I am attaching a barebones version.  I would much> appreciate any help.>> -fREW>>>> On Tue, Sep 30, 2008 at 2:34 PM, Bill Luebkert <dbec...@roadrunner.com>wrote:>>> fREW Schmidt wrote:>>>>> Hello all,>>>>>> I am having the weirdest problem and no one seems to have any idea what>>> it is; so maybe you (the internet :-)  will.  Here is the problem:>>>>>> I am trying to upload a CSV and process it.  I have some dummy code to>>> just print the contents of the file to the log and nothing is working.  Here>>> is the code:>>>>>>        my $uploadHandle = $Input->upload("File");>>>>>>        while(<$uploadHandle>) {>>>            warn $_;>>>        }>>>>>> On the same server I have very similar code and that *does* work.>>>  Furthermore the server does know the filename and firebug clearly shows the>>> contents of the file getting sent to the server.  Does anyone have any ideas>>> of what could cause this?>>>>>>> Guess what - those 3 lines of code won't upload anything.  How about>> stripping>> your script down to the basics and change the URL/passwords to something>> generic>> and re-post so we have something to work with.  We need complete scripts>> with>> warnings and strict turned on preferably.  Run the script locally before>> posting>> and then cut-n-paste it into your email.  Keep it small and complete and>> indicate>> how it fails exactly.>>>>

Recent Messages in this Thread
fREW Schmidt Sep 30, 2008 07:29 pm
Bill Luebkert Sep 30, 2008 07:34 pm
fREW Schmidt Sep 30, 2008 07:53 pm
fREW Schmidt Sep 30, 2008 07:54 pm
Serguei Trouchelle Sep 30, 2008 09:10 pm
fREW Schmidt Sep 30, 2008 09:29 pm
Bill Luebkert Sep 30, 2008 09:57 pm
fREW Schmidt Sep 30, 2008 10:08 pm
Messages in this thread

Previous post: Re: File won't upload