hey
so i decided against using uploadify as i could not get any help on it. i've been now trying to implement a simpler solution. but unfortunately i cannot seem to process the upload code on a single page without receiving the following error:
Warning: fopen() [function.fopen]: Filename cannot be empty in C:\xampp\htdocs\speedycms\manageclient.php on line 205
Warning: fread() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\speedycms\manageclient.php on line 206
Warning: fclose() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\speedycms\manageclient.php on line 208 Error, query failed
this is the code i've been trying to get to work... can you suggest any means of getting it all to work on a single page rather than splitting it up into two apart from ajax (im not too familiar with that)... its all on a single page
any help would be appreciated!
<!-- upload file --->
<?php
if (array_key_exists('uploadfile',$_POST)) {
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
}
$uploadQry = "INSERT INTO upload (name, size, type, content ) ".
"VALUES ('$fileName', '$fileSize', '$fileType', '$content')";
mysql_query($uploadQry) or die('Error, query failed');
echo "<br>File $fileName uploaded<br>";
exit;
}
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'] . '?id=' . intval($client_id); ?>">
<p>
<b>File Upload</b></p>
<p>
<input type="hidden" name="MAX_FILE_SIZE" value="2000000">
<input name="userfile" type="file" id="userfile"><BR />
<input type="hidden" name="uploadfile" value="1"/>
<input name="upload" type="submit" id="upload" value=" Upload ">
</p>
<p> <a href="#viewFiles" class="form" rel="facebox">View files</a>
</p>
<div id="viewFiles" style="display:none;" rel="facebox">
<div style="width:300px; height: 300px;"></div></div></form>