473,748 Members | 5,242 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

upload multiple files----still waiting for your reply

114 New Member
Dear Friends,

I have post this query 4 days ago......but no one replied me.....

I request you all to please help me on this........... ...

I am trying to upload multiple files. But I can't find why it is not working fine. Here is the code.........

numfile.php

[HTML]<form method="POST" action="fileupl oad.php">
<p align="center">
<font face="Verdana" size="2">Number of files</font>
<input type="text" class="text" name="numfiles" size="3" maxlength="3">< br>
<br>
<input type="submit" value="Submit" name="submit" style="font-family: Verdana; font-size: 8pt; font-weight: bold; border: 1px solid #666666; padding: 2"></p>
</form>[/HTML]


fileupload.php

[PHP]
$numoffile = $_POST['numfiles']; //value taking from numfile.php

$file_dir = "files/";

if ($_POST) {
for ($i=0;$i<$numof file;$i++) {
if (trim($_FILES['myfiles']['name'][$i])!="") {
$newfile = $file_dir.$_FIL ES['myfiles']['name'][$i];
move_uploaded_f ile($_FILES['myfiles']['tmp_name'][$i], $newfile);
$j++;
}
}
}
if (isset($j)&&$j> 0) print "<center><f ont family='verdana ' size='2' color='green'>Y our file(s) has been uploaded.</font><br>";
print "<p><h3 style='font-family:verdana; color:green;tex t-align:center'>U pload Files</h3></p><form method='post' enctype='multip art/form-data'>";
for($i=0;$i<$nu moffile;$i++) {

$num = $i+1;
print "<center><s pan style='font-family:verdana; font-size:10pt'>File $num </span> <input type='file' name='myfiles[]' size='30'><br>" ;
}
print "<p align='center'> <input type='submit' name='action' value='Upload'> </p>";
print "</form>"; [/PHP]




Please help me out where is the error.........

Thanks
Deepak
May 11 '07 #1
3 2144
pbmods
5,821 Recognized Expert Expert
Erm... the error would be that there's no file input in your HTML, so nothing's getting uploaded.

http://php.net/manual/en/features.fi...d.multiple.php
May 11 '07 #2
ak1dnar
1,584 Recognized Expert Top Contributor
Try this coding and if you can't understand what i have done here come back to the thread.

I have done some changes to these areas..

1. hidden field.
2. for loops
3. form action

[PHP]
<?php
$numoffile=$_PO ST['numfiles'];


$file_dir = "files/";

if ($_POST['action'])
{
for($x=1;$x<=$n umoffile;$x++)
{
$newfile = $file_dir.$_FIL ES['myfiles'.$x.'']['name'];
move_uploaded_f ile($_FILES['myfiles'.$x.'']['tmp_name'],$newfile);
$j++;
}
}

if (isset($j)&&$j> 0)
print "<center><f ont family='verdana ' size='2' color='green'>Y our file(s) has been uploaded.</font><br>";

if($_POST['submit'])
{
print '<p><h3 style="font-family:verdana; color:green;tex t-align:center">U pload Files</h3></p>
<form action="'.$PHP_ SELF.'" method="post" enctype="multip art/form-data">';

for($i=0;$i<$nu moffile;$i++)
{
$num = $i+1;

print '<center><span style="font-family:verdana; font-size:10pt">File $num </span>
<input type="file" name="myfiles'. $num.'" size="30"><br>' ;

}

print '<p align="center"> <input type="hidden" name="numfiles" value="'.$numof file.'"><input type="submit" name="action" value="Upload"> </p>';

print "</form>";
}
?>
[/PHP]
May 11 '07 #3
ak1dnar
1,584 Recognized Expert Top Contributor
oops i changed this line also.
[PHP]<input type="file" name="myfiles[]" size="30">[/PHP]
with this
[PHP]<input type="file" name="myfiles'. $num.'" size="30">[/PHP]
May 11 '07 #4

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

Similar topics

6
10568
by: x. zhang | last post by:
Hi Guys, We know that we can use <input type=file ...> to upload one file per time to the server. My question is if there are some way to upload multiple files per time to the server. (Of course, we can use <input type=file ...> multiple times and then submit once. But this is not what I want, because we have to click "browse" button several times to select multiple files before submit in this way.) "Upload multiple files PER TIME", I...
1
1152
by: makthar | last post by:
Hi Everyone: I want to make a page for the users to be able to upload multiple files to the server. Presently I use a html file field but it allows selection of a single file only. Does any one have a better solution or point me in that direction ? Thanks in advance.
1
5134
by: Susan | last post by:
Is it possible to use PHP with VBScript or JavaScript to upload multiple files. I'd like to automate the upload of a complete directory (not using FTP). I don't need a common form with several upload boxes. Thanks in advance, Susan
3
1880
by: JFB | last post by:
Hi All, It's a way to upload multiple files on a web site using vb.net 2005? I see the uploadFile tool, but it's only for one file. Any ideas, examples, links??? Tks in advance JFB
0
1367
by: deepaks85 | last post by:
Dear Friends, I am trying to upload multiple files. But I can't find why it is not working fine. Here is the code......... numfile.php <form method="POST" action="fileupload.php"> <p align="center"> <font face="Verdana" size="2">Number of files</font> <input type="text" class="text" name="numfiles" size="3" maxlength="3"><br>
0
1118
by: deepaks85 | last post by:
Dear Friends, I am trying to upload multiple files. But I can't find why it is not working fine. Here is the code......... numfile.php <form method="POST" action="fileupload.php"> <p align="center"> <font face="Verdana" size="2">Number of files</font> <input type="text" class="text" name="numfiles" size="3" maxlength="3"><br>
10
4821
by: Sebarry | last post by:
Hi, I'm using the code at http://the-stickman.com/web-development/javascript/upload-multiple-files-with-a-single-file-element/ to upload multiple files with a single file element. It works fine but for each file uploaded I want to store the contents of a text file which describes the file. I've tried to understand the code but I'm not a Javascript nor XML guru. Would anyone be kind enough to look at the code and tell me where I'm going...
43
9910
by: bonneylake | last post by:
Hey Everyone, Well this is my first time asking a question on here so please forgive me if i post my question in the wrong section. What i am trying to do is upload multiple files like gmail does. I found a script that does this on easycfm.com (Topic 13543). But anyway when i try to upload multiple files it will create multiple records in my database (like it should), but it wont upload multiple files. What ever file i choose to upload...
0
1703
AnuSumesh
by: AnuSumesh | last post by:
Hi We have an application where we can upload file from client machine to any shared device on the network. Now our requirement is to upload multiple files over the network. e.g. to path domain_name\computer_name\share_name\ And I have to write the code in asp. Can anyone help me? can anyone give me some code to upload multiple files over network where destination path is in domain_name\computer_name\share_name\ format?
0
8987
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8826
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9534
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9316
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9241
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8239
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6793
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4867
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2777
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.