I can upload images and modify them. The problem is that the images are stored in the database in the form of binary stream blob, so I don't know how to read this address, the image address in the database remains unchanged when the image name is modified and the address is not modified.
------ Solution --------------------
Convert image to binary
Suggestion: encode binary data with base64 before joining the database. otherwise, some special symbols may cause insertion failure.
------ Solution --------------------
Upload processing:
// Because the uploaded image is saved in a temporary file
// You only need to read the file to obtain the uploaded image.
$ Fp = fopen ($ _ FILES ["myFile"] ["tmp_name"], "rb ");
$ Buf = addslashes (fread ($ fp, $ _ FILES ["myFile"] ["size"]);
// Create a PDO object
$ Dbh = new PDO ("mysql: host = localhost; port =
3306; dbname = myDatabase "," root "," verysecret ");
// Execute the insert operation and save the result in a variable
$ Result = $ dbh-> query ("insert into employees
(FirstName, lastName, EmpType, age, picture) VALUES
('Myfirst', 'myla', 'myemptype ', 50,' $ buf ')");
// Obtain the number of affected rows
If ($ result-> rowCount ()> 0 ){
Echo ("data inserted. ");
} Else {
Echo ("The INSERT operation cannot be performed. ");
}
// Explicitly close the PDO connection
$ Dbh = NULL;
?>
------ Solution --------------------
If a database exists, you can modify the text as usual...
It can be a string.
------ Solution --------------------
Header ("content-type: image/jpeg"); add
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service