Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: File Upload On Windows 8 and Perl

by marinersk (Priest)
on Jul 04, 2015 at 15:47 UTC ( [id://1133161]=note: print w/replies, xml ) Need Help??


in reply to File Upload On Windows 8 and Perl

Well, the code and HTML looks fairly straightforward; it does use a technique different than the one I tend to use.

I know you're certain you've made no errors, but I'm afraid for me to troubleshoot further, I'd need to see the HTML of the web page, the script as you have it, and precisely what you've entered into the web form.

Perhaps a more talented Monk will come along and be able to infer more without these things.

If I might trouble you to post the codes and inputs, great. If not, good luck in the hunt.

Replies are listed 'Best First'.
Re^2: File Upload On Windows 8 and Perl
by skosterow (Novice) on Jul 04, 2015 at 16:20 UTC

    okay this is wired! I GET THE SAME result with that script you showed me - ummm this HAS to be something my servers doing?? any suggestions??

      I suspect you will have found it upon re-reading the thread, but just in case, see my reply above at Re^5: File Upload On Windows 8 and Perl.

      Further note, you seem to be mixing slashes and backslashes in your filename -- I'm a stickler for consistency, admittedly often beyond what is needed, but experience has taught me that computers and inconsistency mix badly at times.

      Finally, if adjusting the filename string the way you think you should doesn't fix the issue, you might consider having the script display its values to the browser before initiating the actual upload, just to make sure there isn't something else amiss. Input filename, output filename -- anything that could matter. Do not fall again for the trap of presuming to know what does matter. When stuff is broken, it pays to be extremely circumspect.

      print "Content-Type: text/html\n\n"; print "<!DOCTYPE html>\n"; print "<html>\n"; print " <head>\n"; print " <title>My CGI File Upload Test</title>\n"; print " </head>\n"; print " <body>\n"; print " <p>\n"; print "\$upload_dir = [$upload_dir]<br />\n"; print "\$filename = [$filename]<br />\n"; print "\$upload_dir/\$filename = [$upload_dir\/$filename]<br />\n" +; print " </p>\n";

      Another tidbit I ran into from my own experiences -- if the server is a Windows server, sometimes they don't set permissions on TEMPthe way you'd expect, and the CGI uploader temporarily writes there. Total upload failure if you don't have write permissions to the TEMPdirectory. A workaround is to establish a different directory for it to work with as its workspace:

      # Needed to avoid dependence on C:\TEMP being world read+write BEGIN { $TempFile::TMPDIRECTORY = './'; }

      It's been my experience that using './'for $TempFile::TMPDIRECTORYtends to result in the cgi-binor similar directory being used -- but it depends on where your Perl CGI script lives -- in your case, I seem to recall your form invokes it from /test/, so make sure your script has write permission there, or change the value used for $TempFile::TMPDIRECTORY.

        This is the response I get from the snip you posted:
        $upload_dir = [images-user] $filename = [20150608_144833.jpg] $upload_dir/$filename = [images-user/20150608_144833.jpg]
        it looks right! Again like i said I can see the file being created in the directory. I have two monitors and i have the DIR open on one and i hit submit in the other. the script goes through its thing - returns the correct page, the file is created but its like there no data IN the file. grrrr :)
Re^2: File Upload On Windows 8 and Perl
by skosterow (Novice) on Jul 04, 2015 at 16:08 UTC

    Thanks mate! i posted the form above, but i will try using your version and see if i get the same result - then at least i know its my server - not my code hehehe

      To be fair, even if you change the framework, it is always possible -- I would even go so far as to say "likely" -- that you would replicate a logic error (or a typo, like, say, neglecting to double your backslashes inside a quoted string) in the part of the code you have to supply to make a snippet like that work. It seems like changing the framework and getting the same error would implicate the site, but that's not as sure a bet as you'd think.  :-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1133161]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-04-19 02:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found