How to upload multiple and insert multiple images in mysql with php?

Here I have discussed about that how to upload multiple images in MySql with php.I know that there are so many ways for this work but I have discussed here some easy (I think) way for uploading multiple images with the help of php. In this article, I have assumed that you have some basic knowledge of php and want to enhance your knowledge. I have created this script for in so many Project so I thought I should discuss it.

I have created this script with the help of php function. Don’t worry this is very simple function. Here I have added one additional functionality and that if you can also upload images in your desired folder. I have give this option in this script.

1. First of all create form for submitting images and folder.






2. Now you can upload images with help of php and insert in mysql.
Note ! You can change the variable names as per your need.

if(isset($_POST['add_images'])){
     $folder_name=mysql_real_escape_string($_POST['folder_name']);
     $folder_images=$_FILES['folder_images']['name'];
     $folder_images_tmp=$_FILES['folder_images']['tmp_name'];
     
     $file_array=array(
      'filename'=>$folder_images,
      'filetmp'=>$folder_images_tmp,
      );
     $multiplefileUpload=multiplefileUpload($file_array,$folder_name);
     // echo '
';
     // print_r($multiplefileUpload);
     // echo '
'; // die; if($multiplefileUpload['bool']==false){ echo $multiplefileUpload['msg']; }else{ $addimages=addmultipleImages($multiplefileUpload['filename'],$folder_name); // echo '
';
      // print_r($addepaper);
      // echo '
'; // die; if($addimages['bool']==true){ echo 'Files Has been uploaded in '.$epaper_date.' Directory and added in database'; }else{ echo $addimages['msg']; } } }

Now to i am going to explain this script.
Firstly i have checked that for is submitted or not if submitted then store the value of folder and values of images in their corressponding varibale.
Then i am sending this data as array in file uploading function 'multiplefileUpload()'

// multiple File upload
	function multiplefileUpload($file_array,$folder){
		$res=array();
		if(!empty($folder)){
		if(file_exists($folder)){
			for($file=0; $file

0 comments:

Ads

Web Hosting