Dears
I have Developed a System for UPLOAD PDF files in Database.
I Require to rename the file as LA when file is Uploaded in DB.
Here is my Form
<form enctype="multipart/form-data" action="dS.php" method="POST">
<tr>
<td><table width="98%" border="0" cellspacing="0" cellpadding="0" >
<span class="style7 style1">Site Id</span><input type="text" name="id" value="" />
<tr>
<td width="39%"><div align="right"><span class="style7 style1">Upload LA:</span></div></td>
<td width="61%"><!-- MAX_FILE_SIZE must precede the file input field -->
<input type="hidden" name="MAX_FILE_SIZE" value="9999999" />
<!-- Name of input element determines name in $_FILES array -->
<input name="userfile" type="file" /><br /></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="hidden" id="b" name="pa" /></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="" /> </td>
</tr>
</table>
</td>
</tr>
</form>
and here is mu Upload file code
<?php
$id=$_POST['id'];
$path = $_SERVER['DOCUMENT_ROOT'] . '/LAPO/SOUTH/'.$id;
$filename = $path;
if (file_exists($filename)) {
$uploaddir = $_SERVER['DOCUMENT_ROOT'] . "/LAPO/SOUTH/$id/";
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
$uploaddir1 = $_SERVER['DOCUMENT_ROOT'] . "/LAPO/SOUTH/$id/";
$uploadfile1 = $uploaddir1 . basename($_FILES['userfile1']['name']);
$uploaddir2 = $_SERVER['DOCUMENT_ROOT'] . "/LAPO/SOUTH/$id/";
$uploadfile2 = $uploaddir2 . basename($_FILES['userfile2']['name']);
$extension= end(explode(".", $uploadfile));
$extension1= end(explode(".", $uploadfile1));
$extension2= end(explode(".", $uploadfile2));
if ($extension!= "pdf")
{
echo "<b>ERROR:File Format Of Lease Agreement is not Supported, Please Select A PDF File</b><a style=color:#FF0000; href=sendfileS.php><b>-Select Another File</b></a>";
if ($extension1!= "pdf")
{
echo "<b>ERROR:File Format of PO is not Supported, Please Select A PDF File</b><a style=color:#FF0000; href=sendfileS.php><b>-Select Another File</b></a>";
if ($extension2!= "pdf")
{
echo "<b>ERROR:File Format of SPA is not Supported, Please Select A PDF File</b><a style=color:#FF0000; href=sendfileS.php><b>-Select Another File</b></a>";
}
print "</pre>";
echo '<pre>';
if (move_uploaded_file($_FILES['userfile2']['tmp_name'], $uploadfile2)) {
echo "SPA Successfully uploaded.\n";
}
}
else
{
print "</pre>";
echo '<pre>';
if (move_uploaded_file($_FILES['userfile1']['tmp_name'], $uploadfile1)) {
echo "Purchase Order Successfully uploaded.\n";
} else {
echo "Purchase Order file Path is invalid!\n";
}
if ($extension2!= "pdf")
{
echo "<b>ERROR:File Format of SPA is not Supported, Please Select A PDF File</b><a style=color:#FF0000; href=sendfileS.php><b>-Select Another File</b></a>";
}
print "</pre>";
echo '<pre>';
if (move_uploaded_file($_FILES['userfile2']['tmp_name'], $uploadfile2)) {
echo "SPA Successfully uploaded.\n";
}
}
}
else
{
echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "Lease Agreement Successfully uploaded.\n";
} else {
echo "Lease Agreement file Path is invalid!\n";
}
if ($extension1!= "pdf")
{
echo "<b>ERROR:File Format of PO is not Supported, Please Select A PDF File</b><a style=color:#FF0000; href=sendfileS.php><b>-Select Another File \n</b></a>";
if ($extension2!= "pdf")
{
echo "<b>ERROR:File Format of SPA is not Supported, Please Select A PDF File</b><a style=color:#FF0000; href=sendfileS.php><b>-Select Another File \n</b></a>";
}
print "</pre>";
echo '<pre>';
if (move_uploaded_file($_FILES['userfile2']['tmp_name'], $uploadfile2)) {
echo "SPA Successfully uploaded.\n";
}
}
else
{
print "</pre>";
echo '<pre>';
if (move_uploaded_file($_FILES['userfile1']['tmp_name'], $uploadfile1)) {
echo "Purchase Order Successfully uploaded.\n";
} else {
echo "Purchase Order file Path is invalid!\n";
}
if ($extension2!= "pdf")
{
echo "<b>ERROR:File Format of SPA is not Supported, Please Select A PDF File</b><a style=color:#FF0000; href=sendfileS.php><b>-Select Another File</b></a>";
}
print "</pre>";
echo '<pre>';
if (move_uploaded_file($_FILES['userfile2']['tmp_name'], $uploadfile2)) {
echo "SPA Successfully uploaded.\n";
}
}
}
/*echo 'Here is some more debugging info:';
print_r($_FILES);*/
print "</pre>";
} ?>