Multiple image upload using php -
Multiple image upload using php -
i have simple php script allows users upload photos. i'd know how convert script enable user upload multiple photos @ same time.
this part of php script:
if (isset($_files['images'], $_post['album_id'])) { $image = addslashes(file_get_contents($_files["images"]["tmp_name"])); $image_name = addslashes($_files['images']['name']); $image_size = getimagesize($_files["images"]["size"]); $image_temp = addslashes($_files['images']['tmp_name']); $allowed_ext = array('jpg', 'jpeg', 'png', 'gif'); $ex = explode('.', $image_name); $image_ext = strtolower(end($ex)); $album_id = $_post['album_id'];
what changes need create part allow multiple uploads? know there should foreach loop in there somwhere don't know set it.
mike here rough solution, not write entire code here explain logic behind it.
you have 2 ways go , 1 name each , every field manually (which mean limited number of fields add together manually) or utilize array. difference between these 2 methods way "point" them php script. incase utilize predefined name every field can phone call them if utilize array method need utilize format : $_files['fieldname']['#id']
(#id starts 0 number of fields created - 1, can while , go through them all).
so have fields in html page, , in php page go through them using loop. can utilize current php code single upload , go through each , every field , upload them 1 one. here illustration :
for($i = 0; $i < count($_files['filename']); $i++){ // utilize upload script here , create sure replace current filename $_files['filename'][$i] }
php
Comments
Post a Comment