mysql - Uploading files using php very slow in xampp -
i new developing.i have opted php learn coding.so might make mistake learn myself, kindly clarify doubts. have problem in uploading files using php folder.what is, upload file , file saved in folder , name of file alone inserted in database. while uploading file copy file folder used editing purpose original file not disturbed.here problem is, file uploaded name inserted in database. take time upload size of file small.it works while test using local when come in real time issue(slow uploading) face. person incharge in uploading is, uploading file , opening new browser , upload file. when new browser opened files uploaded in previous browser still in process. code have written copy file folder not executed new browser opened upload set of files. using xamp cp v3.2.1.to minimize execution time have set default maximum execution time 30. unable upload file fastly.
below php coding:
<?php // connect database include('connect-db.php'); if (isset($_post['submit'])) { // form data, making sure valid $udate = mysql_real_escape_string(htmlspecialchars($_post['udate'])); $file_array=($_files['file_array']['name']); // check make sure both fields entered if ($udate == '' || $file_array=='') { // generate error message $error = 'error: please fill in required fields!'; // if either field blank, display form again renderform($udate, $file_array, $error); } else { $udate = mysql_real_escape_string(htmlspecialchars($_post['udate'])); if(isset($_files['file_array'])) { $name_arrray=$_files['file_array']['name']; $tmp_name_arrray=$_files['file_array']['tmp_name']; for($i=0;$i <count($tmp_name_arrray); $i++) { if(move_uploaded_file($tmp_name_arrray[$i],"test_uploads/".str_replace(' ','',$name_arrray[$i]))) { // save data database $j=str_replace(' ','',$name_arrray[$i]); echo $j; $udate = mysql_real_escape_string(htmlspecialchars($_post['udate'])); $provider = mysql_real_escape_string(htmlspecialchars($_post['provider'])); $existfile=mysql_query("select ubatch_file batches"); while($existing = mysql_fetch_array( $existfile)) { if($j==$existing['ubatch_file']) echo' <script> function myfunction() { alert("file exists"); } </script>'; } mysql_query("insert ignore batches set udate='$udate', ubatch_file='$j',provider='$provider',privilege='$_session[privilege]'") or die(mysql_error()); echo $name_arrray[$i]."uploaded completed"."<br>"; $src = 'test_uploads'; $dst = 'copy_test_uploads'; $files = glob("test_uploads/*.*"); foreach($files $file){ $file_to_go = str_replace($src,$dst,$file); copy($file, $file_to_go); /* echo "<script type=\"text/javascript\"> alert(\"csv file has been uploaded.\"); window.location = \"uploadbatches1.php\" </script>";*/ } } else { echo "move_uploaded_file function failed for".$name_array[$i]."<br>"; } } } // once saved, redirect view page header("location:uploadbatches1.php"); } } ?>
it takes time because, each , everytime files copied newfolder. exceeds execution time.only copying uploaded files makes uploading , copying files fast.
Comments
Post a Comment