473,394 Members | 1,718 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

multiple images uploader

Any one please help me :i have upload the multiple image on server but i have problem to save the name of these image's name my code as following ...
(test1.php)
Expand|Select|Wrap|Line Numbers
  1. <?
  2.   include_once('connection_db.php');
  3.   $username=$_REQUEST['name'];
  4.   $index=$_REQUEST['cboxcata'];
  5.   if($_REQUEST){
  6.   for($i=1;$i<3;$i++){
  7.   $filename= $_FILES["userfile"]["name"][$i];
  8.                move_uploaded_file($_FILES["userfile"]["tmp_name"][$i], "../upload/".$filename);
  9.  
  10.  
  11.    }
  12.       $q="insert into person(image)values('$filename')";
  13.  
  14.       $r=mysql_query($q);
  15.      header("location:test.php");
  16.  
  17. }
  18.  
  19.  
  20. ?>
  21. htlm file is:
  22. <form name="" action="test1.php" method="post" enctype="multipart/form-data">
  23.  
  24.   <table width="350" border="0" align="center">
  25.     <tr>
  26.       <td colspan="2" align="center"><?=$msg?></td>
  27.     </tr>
  28.  
  29.     <tr>
  30.       <td align="left">Image1:</td>
  31.       <td align="left"><input type="file" name="userfile[1]" /></td>
  32.     </tr>
  33.     <tr>
  34.       <td align="left">Image2:</td>
  35.       <td align="left"><input type="file" name="userfile[2]" /></td>
  36.     </tr>
  37.     <!--<tr>
  38.       <td align="left">Image3:</td>
  39.       <td align="left"><input type="file" name="userfile[]" /></td>
  40.     </tr>
  41.     <tr>
  42.       <td align="left">Image4:</td>
  43.       <td align="left"><input type="file" name="userfile[]" /></td>
  44.     </tr>
  45.     <tr>
  46.       <td align="left">Image5:</td>
  47.       <td align="left"><label>
  48.         <input type="file" name="userfile[]" />
  49.  
  50.       </label></td>
  51.     </tr>-->
  52.     <tr>
  53.       <td colspan="2" align="left"><label>
  54.         <input type="submit" name="Submit" value="Submit" />
  55.       </label></td>
  56.     </tr>
  57.   </table>
  58.  
  59. </form>
Aug 24 '09 #1
1 1448
dgreenhouse
250 Expert 100+
This may help you get started (you'll have to work out sanitizing the input and validation):
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. <?php
  4.  
  5.   if (isset($_POST['submit'])) {
  6.     $uploads = "uploads/";
  7.     print '<pre>';
  8.     print_r($_FILES);
  9.     for ($i=0;$i<count($_FILES['files']['name']);$i++) {
  10.       print $_FILES['files']['name'][$i] . "<br>";
  11.       if (!$_FILES['files']['error'][$i]) {
  12.         move_uploaded_file(
  13.           $_FILES['files']['tmp_name'][$i],
  14.           $uploads . $_FILES['files']['name'][$i]
  15.         );
  16.       }
  17.     }
  18.     print '</pre>';
  19.   }
  20.  
  21. ?>
  22. <form method="post" action="" enctype="multipart/form-data">
  23. <input type="file" name="files[]"><br>
  24. <input type="file" name="files[]"><br>
  25. <input type="file" name="files[]"><br>
  26. <input type="submit" name="submit" value="Upload Files">
  27. </body>
  28. </html>
  29.  
Aug 26 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Plex | last post by:
Ok, I've written this script which is supposed to take an image uploaded by a user and put it in to a database, then at a later date be able to extract the image from the database and display the...
2
by: Plex | last post by:
Ok, I had a more barebones version of this script working, but when I tried to put it in with my larger script, it broke. I think the problem lies somewhere in the uploading, but I'm not sure of...
3
by: Arun | last post by:
Hi, I have simple question to ask. How to write multiple Binary files to the Browser using Asp.Net and Visual C#.net I have seen examples where single binary file is written to browser. ...
2
by: harikrishnan4u | last post by:
How can we check the image size in rad uploader this file uploader is in the rad editor??any one Know
5
by: Good Man | last post by:
Hi everyone I was wondering if some people could comment on the new Flickr uploader at http://www.flickr.com/photos/upload/ I find a couple of things very intriguing, particuarly some things...
1
by: groupie | last post by:
Hi, I'm using the excellent Multiple file uploader ( http://the-stickman.com/web-development/javascript/multiple-file-uploader-mootools-version/ ) After selecting the files (as per the Defaults...
9
by: torso | last post by:
Hi Does someone know a good tutorial for multiple file upload with xmlHttpRequest. I am trying to do directory upload. So I could choose directorys and upload those to the server. Another...
2
by: fran7 | last post by:
Hi, I wonder if anyone could tell me if there is a default upload folder for image uploads in this code or if the code references another file. It works fine but I am trying to change the upload...
6
by: neovantage | last post by:
Hey all, i have installed Uber uploader on my server. and it is working perfectly. It shows progress bar after submitting form. I want that when i upload an image or a file it shows the progress in...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.