what does it do ? i think this useless "echo" will destroy the image data structure,
and do you save you file data correctly ?
// just for reference
// Bail out if the file isn’t really an upload.
if (!is_uploaded_file($_FILES['upload']['tmp_name'])) {
exit('There was no file uploaded!');
}
$uploadfile = $_FILES['upload']['tmp_name'];
$uploadname = $_FILES['upload']['name'];
$uploadtype = $_FILES['upload']['type'];
$uploaddesc = $_POST['desc'];
// Open file for binary reading ('rb')
$tempfile = fopen($uploadfile, 'rb');
// Read the entire file into memory using PHP's
// filesize function to get the file size.
$filedata = fread($tempfile, filesize($uploadfile));
// Prepare for database insert by adding backslashes
// before special characters.
$filedata = addslashes($filedata);
// Create the SQL query.
$sql = "INSERT INTO filestore SET
filename = '$uploadname',
mimetype = '$uploadtype',
description = '$uploaddesc',
filedata = '$filedata'";
// Perform the insert.
$ok = @mysql_query($sql);
if (!$ok) {
exit('Database error storing file: ' . mysql_error());
}
try this code AS IS…and copy the error here again.
public function actionDisplaySavedImage($id='')
{
if($id == null || trim($id)=='') {
echo "error in image, bad ID value [{$id}]";
exit();
}
$model=$this->loadModel($id);
if($model->file_content == null){
echo "error in image, using ID [{$id}] ";
exit();
}
header('Content-Type: '.$model->file_type);
echo $model->file_content;
}
ohh…important, try this code using this, directly on browser, to see what happens: