| | |
I want to upload multiple images to a sever using php/mysql
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Use a file area like this
then in you php script
PHP Syntax (Toggle Plain Text)
<input type="file" name="upload[]" >
PHP Syntax (Toggle Plain Text)
foreach($_FILES['upload'] AS $file) { //HERE YOU DO YOUR FILE SAVING //For the file array }
$me = new Person();
if (isset($_COOKIE)){
$me->eat($_COOKIE);
} else { $me->starve(); }
if (isset($_COOKIE)){
$me->eat($_COOKIE);
} else { $me->starve(); }
•
•
Join Date: May 2008
Posts: 97
Reputation:
Solved Threads: 16
Looping is the way to go as Menster has just shown you here. in your html add as many file input fields as you want but name them all as upload[] so that PHP will take the name upload as an array when it is posted.
You can then loop through the array as you do your saving. I'm just explaining Menster's code
/*Happy coding*/
You can then loop through the array as you do your saving. I'm just explaining Menster's code
/*Happy coding*/
Here is an upload example I created a day or two ago. It needs to be modified a bit, but you get the basic idea.
Its pretty secure, making it so people can't upload scripts to the server and run them.
http://www.daniweb.com/forums/post905365-3.html
Its pretty secure, making it so people can't upload scripts to the server and run them.
http://www.daniweb.com/forums/post905365-3.html
Last edited by kkeith29; Jul 3rd, 2009 at 3:28 pm.
•
•
Join Date: Jul 2009
Posts: 1
Reputation:
Solved Threads: 0
php code
php Syntax (Toggle Plain Text)
if(isset($_POST['submit'])) { $video_title = $_POST['photo_title']; $description = $_POST['description']; $MAX_SIZE = 2097152; $filename = $_FILES['photo']['name']; $filesize = $_FILES['photo']['size']; if($filename!='') { if( $filesize > $MAX_SIZE) { $err_msg = "<font color='red'>Your photo file size should not be exceed </font>"; $filename =$_POST['hidden_file']; } else { if(is_file("../photo/".$_POST['hidden_file'])) { unlink("../photo/".$_POST['hidden_file']); } $filecontent = $_FILES['photo']['tmp_name']; move_uploaded_file($filecontent,"../photo/".$filename); } } else { $filename =$_POST['hidden_file']; } /*****VIDEO UPLOAD SECTION******/ $sql = "UPDATE ".PHOTO." SET photo_title = '$photo_title', description = '$description', photo_file = '$filename', created_date = NOW()"; mysql_query($sql); } $select = "SELECT * FROM ".photo; $read = mysql_query($select); $row=mysql_fetch_object($read); $title = $row->photo_title; $description = $row->description; $video_file = $row->photo_file; ?> html code <table width="100%" height="500" border="0" cellspacing="0" cellpadding="0" > <tr> <td align="center" valign="top"> <table width="100%" border="0" cellspacing="5" cellpadding="5"> <tr> <td width="30%"><h4>:: Photo Gallery</h4></td> <td> </td> <td width="70%"><?php echo $err_msg;?></td> </tr> <tr> <td align="right" class="smallfontbold">Photo Title</td> <td>:</td> <td><input type="text" name="photo_title" id="video_title" value="<?php echo $title;?>"></td> </tr> <tr> <td align="right" valign="top" class="smallfontbold">Photo Description</td> <td>:</td> <td valign="top"><textarea name="description" cols="4" rows="5" id="description" class="mceAdvanced"><?php echo $description;?></textarea></td> </tr> <tr> <td align="right" valign="top" class="smallfontbold">Photo Upload</td> <td valign="top">:</td> <td><input type="file" name="photo" id="photo" onKeyPress="return false;" > <input type="hidden" name="hidden_file" value="<?php echo $photo_file;?>"> </td> </tr> <tr> <td> </td> <td> </td> <td> <div> </div> </td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="submit" value="SUBMIT"></td> </tr> </table> </td> </tr> </table>
Last edited by peter_budo; Jul 8th, 2009 at 7:49 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
![]() |
Similar Threads
- Looking for PHP / MySQL Developer (Web Development Job Offers)
- Looking for a PHP/MYSQL Programmer (Web Development Job Offers)
- Need Highly Experienced PHP/MySQL Programmer $15-$25/hour (Web Development Job Offers)
- PHP/MySQL Programmer Position (Web Development Job Offers)
Other Threads in the PHP Forum
Views: 728 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cookies cron curl database date directory display download dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery limit link login loop mail mediawiki menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search select server sessions sms soap source space speed sql stored structure subdomain syntax system table tutorial update updates upload url validation validator variable video web xml youtube






