php - Allow user to use Text input to create folder director and upload multiple images at the sametime -


how allow user use text input create folder director name , upload multiple images @ same-time. have use http://www.phpgang.com/how-to-upload-multiple-images-jquery-ajax-using-php_453.html , simple php code creating director couldn't pass folder folder director name through jquery.fileuploadmulti.min or jquery.form. check upload.php code below

require 'dbconnection.php';  //the name of directory need create. $directoryname = $_post['folder'];  //check if directory exists. if(!is_dir($directoryname)){     //directory not exist, lets create it.      mkdir('imagefolder/'.$directoryname, 0755); } $output_dir = 'imagefolder/'.$directoryname.'/';   if(isset($_files["myfile"])) {     $ret = array();      $error =$_files["myfile"]["error"];    {          if(!is_array($_files["myfile"]['name'])) //single file         {             $randomnum   = time();              $imagename      = str_replace(' ','-',strtolower($_files['myfile']['name']));             $imagetype      = $_files['myfile']['type']; //"image/png", image/jpeg etc.              $imageext = substr($imagename, strrpos($imagename, '.'));             $imageext       = str_replace('.','',$imageext);             $imagename      = preg_replace("/\.[^.\s]{3,4}$/", "", $imagename);             $newimagename = $imagename.'-'.$randomnum.'.'.$imageext;             $url = "$output_dir$newimagename";              move_uploaded_file($_files["myfile"]["tmp_name"],$output_dir. $newimagename);              //echo "<br> error: ".$_files["myfile"]["error"];                 mysql_query("insert pictures(picture,url,name,folder) values('$newimagename','$output_dir$newimagename','','$output_dir')") or die(mysql_error());                  $ret[$filename]= $output_dir.$newimagename;         }         else         {             $filecount = count($_files["myfile"]['name']);             for($i=0; $i < $filecount; $i++)             {                 $randomnum   = time();                  $imagename      = str_replace(' ','-',strtolower($_files['myfile']['name'][$i]));                 $imagetype      = $_files['myfile']['type'][$i]; //"image/png", image/jpeg etc.                  $imageext = substr($imagename, strrpos($imagename, '.'));                 $imageext       = str_replace('.','',$imageext);                 $imagename      = preg_replace("/\.[^.\s]{3,4}$/", "", $imagename);                 $newimagename = $imagename.'-'.$randomnum.'.'.$imageext;                  $ret[$newimagename]= $output_dir.$newimagename;                 move_uploaded_file($_files["myfile"]["tmp_name"][$i],$output_dir.$newimagename );                         mysql_query("insert pictures(picture,url,name,folder) values('$newimagename','$output_dir$newimagename','','$output_dir')") or die(mysql_error());             }         }     }     echo json_encode($ret);  } 


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -