php fputs iis 6.0

Posted on 2009-12-17
Last Modified: 2013-12-13
Hi there,

When I run the following code on linux/apache server, it correctly creates the file. But when I run it on Windows 2003 IIS 6.0, it still creates the file but they are not valid picture files.

Is there something else I need to do to be able to run this on IIS ?

PS : $campaign['Campaign']['picture'] is a BLOB field in mysql database.
$absDir = WWW_ROOT . 'img' . DS . 'campaign' . DS;

			$filename = $absDir.$id'.jpg';

			$fp = fopen($filename,"w+");

			fputs($fp, $campaign['Campaign']['picture']);


Open in new window

Question by:bilgehanyildirim
    LVL 11

    Expert Comment

    Any error messages?
    Is the "$absDir" variable pointing to the right location?  Moving from Linux to Windows will also change your path structure.

    Author Comment

    No no error. Site is creating the file in the correct location. But when I double click on it, it says (on windows) no preview available.
    LVL 11

    Accepted Solution

    Based on a comment posted here:

    Try this:

    fputs($fp, $campaign['Campaign']['picture'], strlen($campaign['Campaign']['picture']));

    Open in new window


    Author Comment

    Still same, no preview available

    Author Comment

    actually the file created on linux/apache is 13.6 KB, but the file create on IIS is 8.1 KB. Even though I made the changes you mentioned above.

    I am attaching the file that doesn't work

    Author Closing Comment

    It has nothing to the with PHP or IIS, it was mysql error.

    Thanks for the tip though.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    This is a general how to create your own custom plugin system for your PHP application that you designed (or wish to extend a third party program to have plugin functionality that doesn't have it yet).  This is not how to make plugins for existing s…
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now