2

I need some advice where to look for possible reasons for the issue below.

I am running an PHP script for video upload. Video uploads successfully on the server each time. After I do move_uploaded_file from the temp folder to the new folder I have the following code:

$sql_insrt  = "INSERT INTO tbl_videos SET
               video_name       = 'name1',
               v_id             = '12'";
$rs_insrt   = $db -> Execute($sql_insrt);

Now for small video files (1~5MB) the $rs_insrt query executes successfully without any issue. However, when I try to upload a larger video (20MB for example), the $rs_insrt does not get executed. The video file is uploaded in the new folder (as it should) and the $sql_insrt query is correct but the insert query does not go trough.

Do you guys have any idea why this could be?

I have the following configuration in php.ini so I don't think this is the problem:

max_execution_time = 300 
max_file_uploads = 20
max_input_nesting_level = 64 
max_input_time = -1
max_input_vars = 1000
memory_limit = 128M
post_max_size = 100M
upload_max_filesize = 100M
user3132858
  • 609
  • 1
  • 11
  • 27

2 Answers2

0

You can try chunked file upload. I think you have a problem with timeout. When your upload has finished so you can run your mysql statements.

https://github.com/blueimp/jQuery-File-Upload/wiki/Chunked-file-uploads

Yargicx
  • 1,704
  • 3
  • 16
  • 36
0

Ok, so I have finally figured it out. The MySQL version got upgraded and the wait_timeout has been set to 20 sec. Hence the error.

The max allowed value by the hosting provider for wait_timeout is 90 sec - not good enough for my needs so I found a workaround.

I am checking for existing connection and if none, I am closing and then opening new one (example below for ADOdb):

if (!mysql_ping($db)) {
   $db->Close();                        
   $db = ADONewConnection('mysqli');
   $db->Connect('host','user','pass','name') or die("Database not found!");
}
user3132858
  • 609
  • 1
  • 11
  • 27