473,408 Members | 2,441 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,408 software developers and data experts.

hi this is my code for uploading images into data base which is woring fine, but i wa

hi this is my code for uploading images into data base which is woring fine, but i want to upload multiple images an any one help me.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. include 'config.php';
  3. error_reporting(E_ALL ^ E_NOTICE);
  4. if(isset($_POST['submit']))
  5. {
  6. $target = "http://bytes.com/images/";
  7. $target = $target . basename( $_FILES['photo']['name']); 
  8. $name = $_POST['name'];
  9. $pic = ($_FILES['photo']['name']);
  10. $sql = mysql_query("INSERT INTO `myimages` (`name`, `picture`) VALUES ('$name', '$pic');"); 
  11.  
  12. if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
  13. {
  14. echo '<center>Image uploaded Saved Success</center>';
  15. }
  16. else
  17. {
  18. echo '<center>Not Saved</center>';
  19. }
  20. }
  21. ?>
Jan 4 '14 #1
1 1326
Luuk
1,047 Expert 1GB
When using a form like:
Expand|Select|Wrap|Line Numbers
  1. <form action=upload.php enctype="multipart/form-data" method=post>
  2. <input type=file name="file[]"><br>
  3. <input type=file name="file[]"><br>
  4. <input type=submit name=submit><br>
  5. </form>
You should find an array like this in PHP
Expand|Select|Wrap|Line Numbers
  1. Array ( [file] => 
  2.  Array ( 
  3.   [name] => 
  4.     Array ( [0] => filename1.jpg [1] => filename2.jpg )
  5.   [type] => 
  6.     Array ( [0] => image/jpeg [1] => image/jpeg )
  7.   [tmp_name] => 
  8.     Array ( [0] => /tmp/phpx3AyMX [1] => /tmp/phpgQjjyl )
  9.   [error] => 
  10.     Array ( [0] => 0 [1] => 0 )
  11.   [size] => 
  12.     Array ( [0] => 25016 [1] => 90566 ) ) ) 
  13.  
above is the 'formatted' output of print_r($_FILES)

now you refer to (line#5):
$pic = ($_FILES['photo']['name']);

with above example you can use:
$_FILES['file']['name'][0];
and
$_FILES['file']['name'][1];
Jan 4 '14 #2

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

Similar topics

1
by: ruksan | last post by:
I am using CRecordset in MFC ( VC 6) I created a class derrived from CRecordset to access the table (MS Access) "student" (using ODBC). This derrived class was created using class wizard The...
4
by: Paul Copeland | last post by:
Hi, I am using Access2000 and have developed a data base which successfully uses DAO code in some of the forms to update tables. Recently I converted the data base to a split MDE data base and now...
3
by: Carlos | last post by:
Hello Forum, I would appreciate it if you could recommend settings to use auto-vacuum in my version 7.4 database. I am uploading several thousands records in the database at a rate of ~1 second...
3
by: Gavin | last post by:
I need some help, I need the code to allow people that visit my website to be able to upload pictures to a file on my web server. I have been able to get close, but not quite there yet. Set fso...
0
by: alex9128 | last post by:
Hi, I have a VB.NET program with several CR.NET reports using ADO.NET Datasets. It takes data from Visual FoxPro 8.0 database. I have also two computers with VS.NET 2003 installed on both of...
1
by: joe | last post by:
Any articles relating with Uploading images files to server and resize the image by asp.net 2.0
3
by: aaa | last post by:
How can I save data without connecting to data base every time a client's request arrives? If I work on a temporary memory I cannot work with sql queries, but connecting to data base takes time.
1
by: sudheerk | last post by:
already image is in the data base.after log in how to display the image in welcome page using session varable
1
by: rohitsingh0000 | last post by:
Hi i want to import a .dmp file of oracle 9i through code using asp.net with c# . plss provide me the coe as how to make an user interface so that even a simple person can imort the .dmp file with...
0
by: apwuhp | last post by:
We have used a data replication product that has replicated our production data base to another server, both servers are AIX 5.3 operating system and IBM DB2 data bases. The product replicates at the...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.