Php: An error occurred while receiving the input file. The image size is very small and the php Data of the image cannot be opened.
I use php: // input to receive the image code as follows:
$file= file_get_contents('php://input'); $this->filename=time().'.jpg'; $dirname .='Uploads'.DIRECTORY_SEPARATOR.'face'.DIRECTORY_SEPARATOR.'1'; $url=$dirname.DIRECTORY_SEPARATOR.$this->filename; $handle=fopen($url, 'w'); fwrite($handle, $file); fclose($handle);
The uploaded image is received in more than 70 kb and saved in more than 70 bytes. it cannot be opened at all. I use var_dump () to print the received data stream as follows: image%955e0caajw1dwnvnfmwk4j.jpg & submit = % E4 % B8 % 8A % E5 % 82% B3 % E6 % AA % 94% E6 % A1 % 88
Is that true? How can this problem be solved?
Reply to discussion (solution)
Image%955e0caajw1dwnvnfmwk4j.jpg & submit = % E4 % B8 % 8A % E5 % 82% B3 % E6 % AA % 94% E6 % A1 % 88
Is the form control value
To upload images, use the $ _ FILES array.
Because the data stream of the uploaded file is intercepted by php, php: // input can only obtain values of other Form controls.
Image%955e0caajw1dwnvnfmwk4j.jpg & submit = % E4 % B8 % 8A % E5 % 82% B3 % E6 % AA % 94% E6 % A1 % 88
Is the form control value
To upload images, use the $ _ FILES array.
Because the data stream of the uploaded file is intercepted by php, php: // input can only get the values of other Form controls. I want to receive images sent from the android client, android sends images in the form of file streams. Can $ _ FILES receive file streams?
Image%955e0caajw1dwnvnfmwk4j.jpg & submit = % E4 % B8 % 8A % E5 % 82% B3 % E6 % AA % 94% E6 % A1 % 88
Is the form control value
To upload images, use the $ _ FILES array.
Because the data stream of the uploaded file is intercepted by php, php: // input can only get the values of other Form controls. I want to receive images sent from the android client, android sends images in the form of file streams. Can $ _ FILES receive file streams?
Php: // input image data streams, which can only be used
File_put_contents ('images/1.jpg ', file_get_contents ("php: // input "));
Save
No, you will know about print_r ($ _ FILES!
Whatever the client is, what you get through php: // input is
Value named image control: 955e0caajw1dwnvnfmwk4j.jpg
Value for the submit control: % E4 % B8 % 8A % E5 % 82% B3 % E6 % AA % 94% E6 % A1 % 88 (Upper ?? Case)
There is no image data stream.