server doesn't recognize file upload
Posted: Wed Nov 12, 2003 12:52 pm
I'm using a file upload CLASS in my PHP to make file upload code easier. I've set up everything the way it should be (i think). But when I submit a file to be uploaded, I get an error message saying that the upload file field wasn't filled in. So i'm guessing that it doesn't recognize that a file has been selected for upload. Is there something missing in my code...or is it a php.ini issue where something hasn't been set up right?
Here is my code:
and my form has the following variables:
with the upload field labelled as <input type="file" name="candResume">
Here is my code:
Code: Select all
<?php require_once('Connections/EagleMain.php'); ?>
<?php
include("class.upload_files.php");
$upload_class = new Upload_Files;
$upload_class->temp_file_name = trim($_FILESї'upload']ї'resume_tmp']);
$upload_class->file_name = trim(strtolower($_FILESї'upload']ї'resume']));
$upload_class->upload_dir = "resumes/";
$upload_class->upload_log_dir = "resumes/upload_logs/";
$upload_class->max_file_size = 5242880;
$upload_class->banned_array = array("");
$upload_class->ext_array = array(".doc",".txt");
$valid_ext = $upload_class->validate_extension();
$valid_size = $upload_class->validate_size();
$valid_user = $upload_class->validate_user();
$max_size = $upload_class->get_max_size();
$file_size = $upload_class->get_file_size();
$file_exists = $upload_class->existing_file();
if (!$valid_ext) {
$result = "The file extension is invalid, please try again!";
}
elseif (!$valid_size) {
$result = "The file size is invalid, please try again! The maximum file size is: $max_size and your file was: $file_size";
}
elseif (!$valid_user) {
$result = "You have been banned from uploading to this server.";
}
elseif ($file_exists) {
$result = "This file already exists on the server, please try again.";
} else {
$upload_file = $upload_class->upload_file_with_validation();
if (!$upload_file) {
$result = "Your file could not be uploaded!";
} else {
$result = "Your file has been successfully uploaded to the server.";
}
}
?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $HTTP_SERVER_VARSї'PHP_SELF'];
if (isset($HTTP_SERVER_VARSї'QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARSї'QUERY_STRING'];
}
if ((isset($HTTP_POST_VARSї"MM_insert"])) && ($HTTP_POST_VARSї"MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO candidates (candFirstName, candLastName, candAddress, candCity, candState, candZip, candPhone, candFax, candEmail, jobType, coverLetter, candResume, jobID) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($HTTP_POST_VARSї'candFirstName'], "text"),
GetSQLValueString($HTTP_POST_VARSї'candLastName'], "text"),
GetSQLValueString($HTTP_POST_VARSї'candAddress'], "text"),
GetSQLValueString($HTTP_POST_VARSї'candCity'], "text"),
GetSQLValueString($HTTP_POST_VARSї'candState'], "text"),
GetSQLValueString($HTTP_POST_VARSї'candZip'], "text"),
GetSQLValueString($HTTP_POST_VARSї'candPhone'], "text"),
GetSQLValueString($HTTP_POST_VARSї'candFax'], "text"),
GetSQLValueString($HTTP_POST_VARSї'candEmail'], "text"),
GetSQLValueString($HTTP_POST_VARSї'jobType'], "text"),
GetSQLValueString($HTTP_POST_VARSї'coverLetter'], "text"),
GetSQLValueString($HTTP_POST_VARSї'candResume'], "text"),
GetSQLValueString($HTTP_POST_VARSї'jobID'], "int"));
mysql_select_db($database_EagleMain, $EagleMain);
$Result1 = mysql_query($insertSQL, $EagleMain) or die('<p>All fields must be completed!<br>'.
'Error: ' . mysql_error() . '</p>');
$insertGoTo = "thankyou.htm";
if (isset($HTTP_SERVER_VARSї'QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARSї'QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_EagleMain, $EagleMain);
$query_submitResume = "SELECT * FROM candidates";
$submitResume = mysql_query($query_submitResume, $EagleMain) or die('<p>Error processing job candidates from the database!<br> />'.
'Error: ' . mysql_error() . '</p>');
$row_submitResume = mysql_fetch_assoc($submitResume);
$totalRows_submitResume = mysql_num_rows($submitResume);
?>Code: Select all
<form method="post" name="form1" enctype="multipart/form-data" action="<?php echo $editFormAction; ?>">