Jump to content

File Appears Long After Script has Completed?


jebego

Recommended Posts

So, I have a very long script that I really don't think is relevant, here's the last part that actually creates this belated-file:

$image_name = microtime() . ".jpeg";
$handle = fopen("mosaics/" . $image_name,"x+");
imagejpeg($final_image, "mosaics/" . $image_name);

Basically, this creates an image out of the variable $final_image in the directory mosaics/ with a timestamped name.

 

The final image size is ~10.8 mb.

 

So, what happens...

1. I run the php script

2. The script finishes

3. I refresh the mosaics/ directory in my ftp client, but the file isn't there

4. After a few minutes, the file appears

 

I have no idea why this is happening!

 

Thanks for the help!

Link to comment
Share on other sites

Thanks again for the reply!

 

I added the imagedestroy($final_image); line to my code. It didn't fix my problem, but I should have had it there anyways, as not using it can apparently cause memory problems.

 

Any other ideas?

Link to comment
Share on other sites

Thanks again for the reply!

 

I added the imagedestroy($final_image); line to my code. It didn't fix my problem, but I should have had it there anyways, as not using it can apparently cause memory problems.

 

Any other ideas?

write a loop that sleeps http://ca2.php.net/sleep for a few seconds and loops until file exists http://ca2.php.net/manual/en/function.file-exists.php and prints out how many times it looped. Or something.

 

Maybe the jpeg creation function just takes that long. :-/

Link to comment
Share on other sites

Yes! I looked up what you said, and ended up creating a loading bar. This send data to the browser which kept it from timing out.

 

In the end, apparently the creating of the image takes ~10 minutes. I'll be looking for a way to make that smaller later. Thanks a ton!

Link to comment
Share on other sites

Yes! I looked up what you said, and ended up creating a loading bar. This send data to the browser which kept it from timing out.

 

In the end, apparently the creating of the image takes ~10 minutes. I'll be looking for a way to make that smaller later. Thanks a ton!

 

Great. What does your nickname stand for? PM if you don't want EVERYONE to know :)

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.