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
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.

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.