File Upload
Posted: Mon Feb 02, 2009 12:14 am
Hi there, whenever I try to upload a file I get an error message Error Uploading File. Please advice
<?
//include("connection.php");
$connection=mysql_connect($hostname,$user,$pass)
or die ("Unable to connect to the database");
$query4= "Select max(applicant_id) as cvid from moh_job_app";
$result4=mysql_db_query($database,$query4,$connection)
or die("Error in query:$query4.". mysql_error());
if(mysql_num_rows($result4)==0)
{
mysql_close($connection);
}
else
{
list($maxcvid) = mysql_fetch_row($result4);
$imtemp=$_FILES['file1']['tmp_name'];
if(isset($_POST['submit']) && ($_FILES["file1"]["size"] > 0)) {
$imtemp=$_FILES['file1']['tmp_name'];
$uploadfile=$_FILES['file1']['name'];
$fname= $maxcvid . $uploadfile;
$uploaddir = "upload/";
$newfile = $uploaddir . $fname;
if(copy($imtemp, $newfile)) {
print("<h5><center> UPLOAD SUCCESSFUL!</h5></center>");
$connection=mysql_connect($hostname,$user,$pass)
or die ("Unable to connect to the database");
// sql= "Select cvname from mohjob where applicant_id = (SELECT max(applicant_id) from mohjob)" ;
/* $query= "update mohjob
set cvname='$fname'
where applicant_id = (SELECT max(applicant_id) from mohjob)"; */
// $vmaxcvid=$_POST['maxcvid'];
$query= "update moh_job_app
set cvname='$fname'
where applicant_id = '$maxcvid'";
echo"<center>Click <a href ='moh_experience.php?email={$_SESSION['SESSION_UID']}'>here</a> to go to Experience Page</center>";
echo"<body bgcolor=#FCFBE9>";
// header("LOCATION:moh_experience.php");
$result=mysql_db_query($database,$query,$connection)
or die("Error in query:$query.". mysql_error());
mysql_close($connection);
} else {
print("<h3><center>ERROR UPLOADING FILE!</h3></center>");
echo"<body bgcolor=#FCFBE9>";
}} else {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" [ccc] enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value=" 2097152">
<align=left><u>Attach CV</u> <br>
<br>File:<input type="file" name="file1">
<br><input type="submit" name="submit" value="UPLOAD"><br>
<br><font size=2><B> If you do not attach your CV, your application will not be considered.</b>
</form>
<?
}
}
?>
<?
//include("connection.php");
$connection=mysql_connect($hostname,$user,$pass)
or die ("Unable to connect to the database");
$query4= "Select max(applicant_id) as cvid from moh_job_app";
$result4=mysql_db_query($database,$query4,$connection)
or die("Error in query:$query4.". mysql_error());
if(mysql_num_rows($result4)==0)
{
mysql_close($connection);
}
else
{
list($maxcvid) = mysql_fetch_row($result4);
$imtemp=$_FILES['file1']['tmp_name'];
if(isset($_POST['submit']) && ($_FILES["file1"]["size"] > 0)) {
$imtemp=$_FILES['file1']['tmp_name'];
$uploadfile=$_FILES['file1']['name'];
$fname= $maxcvid . $uploadfile;
$uploaddir = "upload/";
$newfile = $uploaddir . $fname;
if(copy($imtemp, $newfile)) {
print("<h5><center> UPLOAD SUCCESSFUL!</h5></center>");
$connection=mysql_connect($hostname,$user,$pass)
or die ("Unable to connect to the database");
// sql= "Select cvname from mohjob where applicant_id = (SELECT max(applicant_id) from mohjob)" ;
/* $query= "update mohjob
set cvname='$fname'
where applicant_id = (SELECT max(applicant_id) from mohjob)"; */
// $vmaxcvid=$_POST['maxcvid'];
$query= "update moh_job_app
set cvname='$fname'
where applicant_id = '$maxcvid'";
echo"<center>Click <a href ='moh_experience.php?email={$_SESSION['SESSION_UID']}'>here</a> to go to Experience Page</center>";
echo"<body bgcolor=#FCFBE9>";
// header("LOCATION:moh_experience.php");
$result=mysql_db_query($database,$query,$connection)
or die("Error in query:$query.". mysql_error());
mysql_close($connection);
} else {
print("<h3><center>ERROR UPLOADING FILE!</h3></center>");
echo"<body bgcolor=#FCFBE9>";
}} else {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" [ccc] enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value=" 2097152">
<align=left><u>Attach CV</u> <br>
<br>File:<input type="file" name="file1">
<br><input type="submit" name="submit" value="UPLOAD"><br>
<br><font size=2><B> If you do not attach your CV, your application will not be considered.</b>
</form>
<?
}
}
?>