Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

php fputs iis 6.0

Posted on 2009-12-17
6
Medium Priority
?
316 Views
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']);
			fclose($fp);

Open in new window

0
Comment
Question by:bilgehanyildirim
  • 4
  • 2
6 Comments
 
LVL 11

Expert Comment

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

Author Comment

by:bilgehanyildirim
ID: 26071537
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.
0
 
LVL 11

Accepted Solution

by:
asafadis earned 2000 total points
ID: 26071587
Based on a comment posted here:
http://www.php.net/manual/en/function.fputs.php#468

Try this:

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

Open in new window

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:bilgehanyildirim
ID: 26071615
Still same, no preview available
0
 

Author Comment

by:bilgehanyildirim
ID: 26071692
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
63.jpg
0
 

Author Closing Comment

by:bilgehanyildirim
ID: 31667270
It has nothing to the with PHP or IIS, it was mysql error.

Thanks for the tip though.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
The viewer will learn how to count occurrences of each item in an array.
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 …
Suggested Courses

580 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