Php: // The input fails to receive the file. the image becomes very small and cannot be opened.

Source: Internet
Author: User
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.

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.