Porting an image upload script Linux to W2K

Posted on 2003-03-17
Medium Priority
Last Modified: 2010-03-05
Can someone tell me from the code chunk below if there is an obvious reason why the image upload script I have been using works fine on Linux/Apache but not on W2K/IIS? I have included the few lines of script that do the actual work of creating the image file on the remote server - the script runs fine but corrupts the image on upload. This is not consistant - sometimes the image won't display in the browser, sometimes it appears but is visibly messed up, plus the OS can never report it's properties.

open (OUTFILE, ">$basedir/$fileName")||die(print "can't open");

while (my $bytesread = read($file, my $buffer, 1024)) {
print OUTFILE $buffer;
close (OUTFILE);

Any help much appreciated.

Question by:stusbikeshed
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 10

Accepted Solution

rj2 earned 800 total points
ID: 8153989
Add the line below after open
LVL 10

Expert Comment

ID: 8154003
Linux don't have separate binary mode and text mode.
Windows does.

Expert Comment

ID: 8158224
the file seperator in windows is "\", in unix its "/"

that could be part of your problem too.


Author Comment

ID: 8168598
Thanks RJ2!

I've not had a chance to check it yet but I had a thought that this could be the problem too. Your confirmation earns 200 points. Thanks again.


Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question