I have a php scrip that looks like this:
if(isset($_FILES["file"]["name"])){
for($i=0; $i<count($_FILES["file"]["name"]);$i++) {
// move file to folder
move_uploaded_file($_FILES["file"]["tmp_name"][$i],
"/pathToFolder/" . $_FILES["file"]["name"][$i]);
//execute script on file
exec('wscript "../Run_Proc.vbs"');
}
}
try {
$db = new PDO("mysql:host=".$hostname.";dbname=test;charset=utf8", $username, $password);
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
$query = "SELECT * FROM test ORDER BY temp_id DESC LIMIT 1";
$stmt = $db->query($query);
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode($rows);
Basically I take files uploaded through html page and run an external VBscript against them. I had originally approached this by moving all the files (at once) to a specified folder, then calling the VBscript to run on all the files in that folder (this took around 3-4 minutes).
So I decided to move the files one at a time then exec the script once for each file, so I could easily handle errors through my php each time the script was executed. However, I started seeing a timeout error:
Fatal error: Maximum execution time of 30 seconds exceeded
referencing the line after my exec() statement.
This did not make sense to me at first because my VBscript was running for much longer than 30 seconds before with no errors. I'm guessing it has to do with the fact that I am calling the exec multiple times, can anyone clue me in on whats going on here? It's not that big of a deal to go back to only calling exec() once I would just like to know why it is not working as expected :-)
And yes I do know that you can temporarily extend the time limit but it doesn't appear that I should have to....the VBScript is certainly never running for more than 30 seconds, and the php script is running for the same amount of time so what is it about multiple calls that causes this?