I'm trying to upload a file. I use to get the fread(): supplied argument is not a valid stream resource error, but then I placed the code in an if statement with file_exists.
The problem is, the if statement never gets executed.
Anyone know what's going on here?
The problem is, the if statement never gets executed.
Code:
if ($_POST)
{
include ('scripts/db_connect.php');
$reviewId = $_POST['review_id'];
$form_data = $_POST['form_data'];
if (file_exists($form_data))
{
$data = addslashes(fread(fopen($form_data, "r"), filesize($form_data)));
$query = "INSERT INTO uploads (report_id, report_data, report_filename, report_filesize, report_filetype)"
. "VALUES (" . $reviewId . ",'" . $data . "','" . $form_data_name . "','" . $form_data_size . "','" . $form_data_type. "')";
if (mysql_query($query))
{
// Upload successfull
?>
<div id="success_box">
<div id="success_box_text">The report has been uploaded successfully.</div>
</div>
<?php
}
}
else
{
echo "File not found";
}
include ('scripts/db_close.php');
}
Comment