I was wondering if anyone could help me. I would like people to upload files to the server from their computer. The problem is whenever the user hits the submit button, I get the following error "Your submission could not be processed due to a system error. We apologize for any inconvenience". What am I doing wrong? Thanks in advance. To be more precise here is the following code.
Code: Select all
<?php
$page_title = 'Upload a File';
$counter = 1;
if (isset($_POST['submitted'])) {
require_once ('../mysql_connect.php');
for ($i = 0; $i < $counter; $i++) {
$filename = 'upload' . $i;
if (isset($_FILES[$filename])&& ($_FILES[$filename]['error'] != 4)) {
$query = "INSERT INTO resume (file_name, file_size, file_type) VALUES ('{$_FILES[$filename]['name']}', {$_FILES[$filename]['size']}, '{$_FILES[$filename]['type']})";
$result = mysql_query ($query);
if ($result) {
$upload_id = mysql_insert_id();
if (move_uploaded_file($_FILES[$filename]['tmp_name'], "../uploads/$upload_id")) {
echo '<p>File number ' . ($i + 1) . ' has been uploaded!</p>';
} else {
echo '<p><font color="red">File number ' . ($i + 1) . ' could not be moved.</font></p>';
$query = "DELETE FROM resume WHERE upload_id = $upload_id";
$result = mysql_query ($query);
}
} else {
echo '<p><font color="red">Your submission could not be processed due to a system error. We apologize for any inconvenience.</font></p>';
}
}
}
mysql_close();
}
?>
<form enctype="multipart/form-data" action="add_file.php" method="post">
<fieldset><legend>Fill out the form to upload a file:</legend>
<input type="hidden" name="MAX_FILE_SIZE" value="524288">
<?php
for ($i = 0; $i < $counter; $i++) {
echo '<p><b>File:</b> <input type="file" name="upload' . $i . '" /></p>';
}
?>
</fieldset>
<input type="hidden" name="submitted" value="TRUE" />
<div align="center"><input type="submit" name="submit" value="Submit" /></div>
</form>
Here is the link to the page to test it.
http://www.rodriguezstudios.com/resume/ ... d_file.php
Thanks in advance.