in reply to Re^3: File Upload On Windows 8 and Perl
in thread File Upload On Windows 8 and Perl

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 :)

Replies are listed 'Best First'.
Re^5: File Upload On Windows 8 and Perl
by marinersk (Priest) on Jul 04, 2015 at 17:15 UTC

    Okay, there's some basic checking on your part that needs to be done -- I'll get to that in a moment.

    At this point I would definitely examine the most excellent suggestion raised by RichardK in Re^5: File Upload On Windows 8 and Perl. Hard evidence is always better than guesses, so take anything you can get in that space. Software engineering is, after all, a blend of art and science.

    Things you'll need to poke around and check -- confirm that images-user is not at the root (i.e., should it be /images-useror \images-userlike you coded it), or should it be a subdirectory of your CGI directory as the browser debugging has shown it to be, etc. -- only you can check those, and you need to try to catch yourself at your own assumptions.

    An example of such an error: What if the file you are seeing was placed there by an early test which failed for a completely different reason, but you never deleted it, and now you are not writing to the same location? It would be completely easy and understandable to make the mistake -- and it would be exactly that -- of assuming that just because the file is in the right place, that your current script is trying to write it there.

    Second-guessing yourself is part science, part art, to be sure; but it is an absolutely critical skill to develop in this profession. You know this, I suspect -- just highlighting that a common trap is to make an assumption and move right past critical analysis. You're not allowed to ask how I know this.  :-)

    Finally, also consider if necessary the use of the TEMPdirectory override I noted above.

    I know it feels like you're circling the problem and not getting at it -- but if you systematically eliminate all the possibilities, and pay attention to what you see whilst you're hunting, odds are you'll find it eventually. Patience, Persistence, Attention to Detail -- all key tools in the troubleshooter's toolbox.

    I would be interested to know when you resolve this; and always, toss out more questions if they come up.

      thanks again mate - and i will TRY ANYTHING :)

      okay I KNOW for sure that its creating the file because i use two monitors - i submit on one and have the DIR open in another. I can see the file being created and then i delete it after i do some changes to the script or permissions then delete it again hehehe

      as Im posting here im also doing some hunting on the net. I also found the temp dir problem and have set permissions to those directories as well. so im stumped!

        You know, we're being a bit silly here. RichardK gave us a way to check for errors on the reading the input.

        Your code doesn't check for errors on writing the output.

        Other random thoughts:

        • Maybe try catching the creation of the temporary file in the TEMP directory using that second monitor? This assumes the file upload is taking long enough that you can do this, of course.
        • Switching to my technique for reading the file might give you more granular control over the I/O -- maybe you can throw some more debugging statements in to display to the browser whilst the file is being processed. I've never tried this myself in a CGI upload context, but in ancient times I've used it to isolate problems on regular file I/O.