Jump to content

Recommended Posts

My php code seems to be executing prematurely.  I am trying to download a file and then delete it if it is too small as follows:

 

//this just tells curl to save a file ($file) and print info about the transfer
$grab->get_file($url,$conn,$proxy);

if (filesize($file)>60000)
{
                echo "file was too small";
	unlink($file);
}

 

 

Now, the file i am downloading is big enough and curl reports that back to me, but php is detecting as too small and deleting it:

 

 

Why do I think this is b/c php is prematurely executing my code????  Glad you asked!  If I change filesize to a smaller number e.g. 30,000  then it will work!  Maybe this is a bug  ???

 

//this just tells curl to save a file ($file) and print info about the transfer
$grab->get_file($url,$conn,$proxy);

if (filesize($file)>30000)
{
                echo "file was too small";
	unlink($file);
}

Link to comment
https://forums.phpfreaks.com/topic/133939-premature-code-execution/
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.