/    Sign up×
Community /Pin to ProfileBookmark

Multiple file uploading with updatation of database field

I hv problem with database update at the same time with different field of different file uploading, So i use multiple file uploading but i m unable to update the field of database……….. Here is my code

<?php
if($_POST)
{
if($_
FILES[info])
{
//print “<PRE>”;
//print_r ($_FILES[info]);
foreach($_
FILES[info][name] as $key => $error)
{
$name = $_FILES[info][name][$key];
$tmp_name = $_
FILES[info][tmp_name][$key];
$target_path = “FILES/”.rand(1, 10000).”_”.$name;
$copy = copy($tmp_name, $target_path);
mysql_query(“UPDATE `client` SET `pan`=’$tarbget_path’ WHERE `id`=’1′”)
}
}
}
?>
<FORM METHOD=POST ACTION=”” enctype=”multipart/form-data”>
<TABLE width=”100%” align=”center”>
<TR>
<TD>Pan Details</TD>
<TD></TD>
<TD><INPUT TYPE=”file” NAME=”info[]”></TD>
</TR>
<TR>
<TD>Tan Details</TD>
<TD></TD>
<TD><INPUT TYPE=”file” NAME=”info[]”></TD>
</TR>
<TR>
<TD>Vat Details</TD>
<TD></TD>
<TD><INPUT TYPE=”file” NAME=”info[]”></TD>
</TR>
<TR>
<TD>Service Tax</TD>
<TD></TD>
<TD><INPUT TYPE=”file” NAME=”info[]”></TD>
</TR>
<TR>
<TD></TD>
<TD></TD>
<TD><INPUT TYPE=”submit” value=”submit”></TD>
</TR>
</TABLE>
</FORM>

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@chickenlandJun 03.2011 — As far as the PHP goes, try this:

[code=php]<?php
if($_POST)
{
if($_FILES['info'])
{
//print "<PRE>";
//print_r ($_FILES[info]);
foreach($_FILES['info']['name'] as $key => $error)
{
$name = $_FILES['info']['name'][$key];
$tmp_name = $_FILES['info']['tmp_name'][$key];
$target_path = "FILES/".rand(1, 10000)."_".$name;
$copy = copy($tmp_name, $target_path);
$sql = "UPDATE client SET pan='$target_path' WHERE id='1'";
echo $sql . '<br />';
mysql_query($sql) or die(mysql_error());
}
}
}
?>[/code]


It should echo out the query so you can see that it is working.

I assume you are including database connection details from an external file?
×

Success!

Help @sparkofram spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...