Jump to content

[SOLVED] writing a file only sometimes


bobinindia

Recommended Posts

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

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.