$handle = fopen('http://...图片地址', 'r');$content = '';while(!feof($handle)){ $content .= fread($handle, 8080);}fclose($handle);$sql = "INSERT INTO chat_msg (data) VALUES('$content')";
The above code cannot be saved when you insert it.
Reply content:
$handle = fopen('http://...图片地址', 'r');$content = '';while(!feof($handle)){ $content .= fread($handle, 8080);}fclose($handle);$sql = "INSERT INTO chat_msg (data) VALUES('$content')";
The above code cannot be saved when you insert it.
Are you sure you want to save it as a base64 ...?
You said that there should be a folder in the local
Directly with Write
Why do you want to save the picture, not the address?
To use binary storage
Maybe your $content size exceeds the data size of the field setting (or default)
Database store pictures are not all stored a picture address???
According to the above code $content is a binary file, strlen length estimates are over 20,000, estimated beyond the limits of your database insert field.
I think you should be the first to save the picture to the local, the database as long as the image path is stored. I don't see the practice of putting files directly into the data at the moment.
I rub, you do this kind of writing I have to say very sb.
Please don't be angry, listen to me slowly.
$data = file_get_contents('图片网址');file_put_contents('图片存储的路径和文件名');// 如file_put_contents('./download/test.jpg',$data);//然后,数据库存储这个图片的存储地址就可以了,例如:$sql = "INSERT INTO chat_msg (data) VALUES('download/test.jpg')";
Of course, the file name of each store file name is not the same, you find a way to name it, I do not explain more.