Dear,
I make a php page to upload the images, pdf, swf etc etc for specific orginisation entered in same form.
In the form i made the input type files to upload a maximum of three files but i know how to upload one of them only. here i upload my code used for upload form page called nework.php and the process page called addworkprocess.php
anyone help me how to upload the second and third file in the same time with addworkprocess.php? Apart from that part from process page i made the types of images like png and jpeg, anyone tell me how to make it to upload swf and pdf files? I appriciate your help.
here is the code of form page:
<?php
require("headerloggedin.php");
?>
<?php
?>
<div id="content">
<div id="topcontent">
<p id="titles" align="center">Add Category</p>
<form enctype="multipart/form-data" method="post" action="addworkprocess.php">
<input type="hidden" name="idofuser" value="<?php echo $userid;?>"/>
<table align="center" bgcolor="#999999">
<tr>
<td id="normaltxt">Organisation Name:</td>
<td><input type="text" name="organisation" /></td>
</tr>
<tr>
<td id="normaltxt">Description of Work:</td>
<td><input type="text" name="description" /></td>
</tr>
<tr>
<td id="normaltxt">Add First Work:</td>
<td width="50px"><input type="file" name="first" id="file"></td>
</tr>
<tr>
<td id="normaltxt">Add Second Work:</td>
<td width="50px"><input type="file" name="second" id="file"></td>
</tr>
<tr>
<td id="normaltxt">Add Third Work:</td>
<td width="50px"><input type="file" name="third" id="file"></td>
</tr>
<tr>
<td colspan="2"><input id="editfrmbtn" type="submit" value="Add" /></td>
</tr>
</table>
</form>
</div>
</div>
<?php
require("footerloggedin.php");
?>
and here is the process page:
<?php
require("headerloggedin.php");
?>
<div id="content">
<div id="topcontent">
<?php
$userid = $_POST["idofuser"];
$nameoforganisation = $_POST["organisation"];
$description = $_POST["description"];
$allowedExts = array("gif", "jpeg", "jpg", "png", "pdf", "swf");
$foldername = "images/icons/";
$imgname = ($_FILES["first"]["name"]);
$imgtype = ($_FILES["first"]["type"]);
$imgsize = ($_FILES["first"]["size"]);
$extension = end(explode(".", $imgname));
if ((($imgtype == "image/gif")
|| ($imgtype == "image/jpeg")
|| ($imgtype == "image/jpg")
|| ($imgtype == "image/pjpeg")
|| ($imgtype == "image/x-png")
|| ($imgtype == "image/png")
|| ($imgtype == "application/pdf")
|| ($imgtype == "application/swf"))
&& ($imgsize < 200000000)
&& in_array($extension, $allowedExts))
{
if ($_FILES["first"]["error"] > 0)
{
echo "Return Code: " . $_FILES["first"]["error"] . "<br>";
}
else
{
echo "Upload: " . $imgname . "<br>";
echo "Type: " . $imgtype . "<br>";
echo "Size: " . ($imgsize / 1024) . " kB<br>";
echo "Temp file: " . $_FILES["first"]["tmp_name"] . "<br>";
if (file_exists($foldername . $imgname))
{
echo $imgname . " already exists. ";
}
else
{
move_uploaded_file($_FILES["first"]["tmp_name"],"images/icons/" . $imgname);
$query = "INSERT INTO gallery (userid, orgname, description, folder, file, name) VALUES ('$userid', '$nameoforganisation', '$description', '$foldername', '$imgname', '$imgtype')";
$db->query($query);
echo "Stored in: " . $foldername . $imgname;
}
}
}
else
{
echo "Invalid file";
}
?>
</div>
</div>
<?php
require("footerloggedin.php");
?>
Thanks for your help.
marifard