A few days ago, I was working on this function. more than eight hundred members were generated by more than eight hundred systems. I uploaded images to more than system members, and then put the image names in the database.
Step 1:
The first step is to upload the image to the corresponding image directory and directly use the existing upload class in the framework:
Set_ext (array ('zip '); $ path = 'Directory name'; if (! Io: mkdir ($ path) // create directory {throw new Exception ("unable to Create File Upload Directory: $ path ");} $ upload-> set_path ($ path); if (! $ Upload-> is_allow_ext ($ _ FILES ['files '] ['name']) {$ this-> show_message ('zip-format data required', '0 ', NULL, TRUE) ;}$ result = $ upload-> save ($ _ FILES ['files']); $ archive = new Archive_Zip (); $ archive-> set_target ($ path)-> decompress ($ result ['file']); unlink ($ result ['file']); // Delete the used zip; $ this-> show_message ('imported successfully', '1', array ('text' => 'return to import page ', 'href '=>' *** jump link address *** '), TRUE);} catch (Exception $ e) {$ this-> show_me Ssage ('image import failed', '0', NULL, TRUE) ;}}?>
Step 2:
After the image is uploaded, retrieve the image names of all system members in the directory, and traverse the image. Think about it and you don't have to worry about it. php comes with the glob function ();
The glob () function returns a file name or directory that matches the specified mode.
This function returns an array containing matching files/directories. If an error occurs, false is returned.
In the loop process, because I only want to get the image name, I replaced the previous directory with null.
Step 3:
After listing all the images, you should insert the image file name into the database.
Write a loop.
First, SELECT ........ Find out the system members and calculate the number of system members,
Execute ()-> as_array ();?>
Then recycle and insert it into the database:
$ Files [$ I],); DB: update ('Member table')-> set ($ data)-> where ('System member id', '= ', $ member [$ I] ['System member id'])-> execute ();}?>
OK. That's it.