bobinindia Posted June 20, 2008 Share Posted June 20, 2008 So this is the code that writes to a text file: $fp = fopen('imagecode.php', 'w'); $vari = "<?php echo 'Image=".$theimage."'; ?>"; fwrite($fp, "$vari"); fclose($fp); Nothing too unusual there. Permissions are fine as it does write sometimes. $theimage is a file uploaded by a user. Testing on a mac I noticed that if an image in Finder has a preview icon it won't be written to this file. Any other image will. All jpgs. Any idea what that could be? Link to comment https://forums.phpfreaks.com/topic/111155-solved-writing-a-file-only-sometimes/ Share on other sites More sharing options...
lemmin Posted June 20, 2008 Share Posted June 20, 2008 Are you sure it isn't getting written or is it just not displaying correctly? I don't know what Image="" is for, but if $theimage has a quote (") character in it, it will mess up the string. In any case, I'm pretty sure the issue is caused by something other than the code here. Link to comment https://forums.phpfreaks.com/topic/111155-solved-writing-a-file-only-sometimes/#findComment-570488 Share on other sites More sharing options...
bobinindia Posted June 20, 2008 Author Share Posted June 20, 2008 I have checked each time i uploaded the file the content of the imagecode.php. It only changed when the image had no image icon. The images are being uploaded and entered into the database as the images upload id is going up every time i run it regardless of the preview icon. This is an example of what is written in the file. <?php echo 'Image=images/uploaded/280.jpg'; ?> No unusual characters to break the string. Link to comment https://forums.phpfreaks.com/topic/111155-solved-writing-a-file-only-sometimes/#findComment-570501 Share on other sites More sharing options...
lemmin Posted June 20, 2008 Share Posted June 20, 2008 Is there any other code around the code that you have shown that could conditionally determine whether or not it is executed? Link to comment https://forums.phpfreaks.com/topic/111155-solved-writing-a-file-only-sometimes/#findComment-570557 Share on other sites More sharing options...
bobinindia Posted June 21, 2008 Author Share Posted June 21, 2008 Yes there was an if statement that wasn't noticed by me. Image size dependent. Thanks Lemmin. Link to comment https://forums.phpfreaks.com/topic/111155-solved-writing-a-file-only-sometimes/#findComment-570775 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.