I have written code to upload a file using a form and the uploader script…
This code was working great for WEEKS until yesterday morning and now it has a problem loading the files.
I’m at a total loss since nothing has changed in the code or on the server.
The files are uploaded to a directory /var/tmp/uploads which is chmod 777 and chown root root.
The permissions on the php scripts is 755.
I am running PHP version 5.2.4
I have checked the php.ini and the file_uploads is set to ON and the size is 2M. The files are much smaller than this…
I’m running on a Linux Ubuntu 5.12…
The code is as follows:
file_select.php
<!--<form enctype="multipart/form-data" action="uploader.php" method="POST">-->
<form method="post" name="form1" id="form1" enctype="multipart/form-data" action="uploader.php">
<table align=center>
<tr>
<td>Client: </td>
<td><?php
if($db == '10.0.0.xx'){
mysql_connect("10.0.0.xx",xxx,xxx);
@mysql_select_db(xxx) or die( "Unable to select database");
}
if($db == '10.0.0.xx'){
mysql_connect("10.0.0.26",xxx,xxx);
@mysql_select_db(xxx) or die( "Unable to select database");
}
if($db == '10.0.0.xx'){
mysql_connect("10.0.0.xx",mysqluser,mysqluser);
@mysql_select_db(xxx) or die( "Unable to select database");
}
$query="SELECT * FROM Client_table WHERE ClientBranch = '$branch' ORDER BY ClientName";
$result=mysql_query($query);
echo '<select name="ClientName">';
while($nt=mysql_fetch_array($result)) { // Array or records stored in $nt
echo '<option value="'.$nt[ClientName].'|'.$nt[ClientKey].'|'.$nt[AccountNo].'">' .$nt['ClientName'].' - '.$nt[AccountNo].'</option>';
}
echo '</select>'; // closing list
?>
</td>
</tr>
<tr>
<td><input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: </td>
<td><input name="uploadedfile" type="file" /></td>
</tr>
<tr>
<td> Email for Error Report</td>
<td><input type=text name=error_mail value="<? echo $blank ?>" ></td>
</tr>
<tr>
<td colspan=2>   </td>
</tr>
<tr>
<input type="hidden" name="branch" value="<? echo $branch ?>">
<input type="hidden" name="db" value="<? echo $db ?>">
<input type="hidden" name="login" value="<? echo $login ?>">
<input type="hidden" name="we_date" value="<? echo $we_date ?>">
<td colspan=2 align=center><input type="submit" value="Upload File" /> </td>
</tr>
</table>
</form>
uploader.php
session_start();
include("connect.php");
$login=$_REQUEST['login'];
$branch=$_REQUEST['branch'];
$db=$_REQUEST['db'];
$weekending_date=$_REQUEST['weekending_date'];
$we_date=$_REQUEST['we_date'];
$error_mail=$_REQUEST['error_mail'];
$_SESSION['login']=$login;
$_SESSION['branch']=$branch;
$_SESSION['db']=$db;
$client = explode("|", $_REQUEST['ClientName']);
$client_name=$client[0];
$client_key=$client[1];
$client_acno=$client[2];
$_SESSION['client_key']=$client_key;
$_SESSION['client_acno']=$client_acno;
$_SESSION['client_name']=$client_name;
$target_path = "/var/tmp/uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
//echo "The file ". basename( $_FILES['uploadedfile']['name']).
//" has been uploaded";
$filename=$_FILES['uploadedfile']['name'];
?>
<script language="JavaScript">
window.location.href='check_import_rules.php?branch=<? echo $branch?>&db=<? echo $db?>&login=<? echo $login?>&client_key=<? echo $client_key?>&client_name=<? echo $client_name?>&client_acno=<?echo $client_acno?>&filename=<? echo $filename?>&weekending_date=<? echo $weekending_date?>&error_mail=<? echo $error_mail?>';
</script>
<?
} else{
echo "There was an error uploading the file, please try again!";
}
?>
As I said, this code has been working for weeks and suddenly started echo-ing the “There was a problem uploading the file, please try again!” error.
Can anyone spot what is causing this because I’m totally stuck!
Thanks