i am trying to get the uploaded image inserted into mysql database but i get this error msg. help please. here is the error i get
Array
(
[name] => Zonsondergang.jpg
[type] => image/jpeg
[tmp_name] => /tmp/phpU9qSru
[error] => 0
[size] => 71189
)
data/Zonsondergang.jpg test file successfully loaded
Warning: file_get_contents(/tmp/phpU9qSru) [function.file-get-contents]: failed to open stream: No such file or directory in /home/meer/domains/skyup.nl/public_html/upload_Class/upload.php on line 68 Error! Failed to insert the file1
here is my code for uploading image and inserting the image into database
include('../inc/con_inc.php');
// Defining Class
$uploaded = new upload;
// Set Max Size
$uploaded->set_max_size(350000);
// Set Directory
$uploaded->set_directory("data");
// Set Temp Name
$uploaded->set_tmp_name($_FILES['file']['tmp_name']);
// Set file size,
$_FILES['file']['size'] is automaticly get the size
$uploaded->set_file_size($_FILES['file']['size']);
// Set File Type,
$_FILES['file']['type']
$uploaded->set_file_type($_FILES['file']['type']);
// Set File Name,
$uploaded->set_file_name($_FILES['file']['name']);
// Start Copy Process
$uploaded->start_copy();
$name=($_FILES['file']['name']);
$data=(file_get_contents($_FILES['file']['tmp_name']));
$query="INSERT INTO download(name,data) VALUES('$name','$data')";
if ($result){
echo 'Success! Your file was successfully added!';
}else{
echo 'Error! Failed to insert the file' ;
$result=mysql_query($query) or die ('开发者_如何学JAVAquery fout');
}
here is the stracture of table:
create table download (
id int primary key not null
auto_increment,
name varchar(60),
data longblob)
$data=(file_get_contents($_FILES['file']['tmp_name']));
you can't do that since you've just uploaded your file with the upload
class.
you should have a method or a variable from witch you get the actual uploaded file, something like: $uploaded->get_file()
you should get file content from there (the file uploaded in your 'data' folder)
精彩评论