I'd like to ask, little brother. How to get a picture from a URL, popular point is to get a picture through get

Source: Internet
Author: User
I'd like to ask. How to get a picture through a URL, popular point is how to get the image by get?
The company's iOS says he can only encapsulate the picture as a stream of data, then pass it through the parameters, and then the parameters are too long for the problem to pass.
I would like to ask, this is my technical problem, very much hurt Ah, I am a fresh graduate.
In the school four years have not heard can use Gey way to preach pictures, is I see too short?

I said I was powerless, everyone thought I was to spray iOS, then spray me, by the way to get a solution to the way, kneeling thanks.
------Solution--------------------
Did not hear, wait for the bull, get maximum only 1024 bytes, and so the cattle people to solve
------Solution--------------------
No iOS, but I'm guessing it's not through get.

Reference Manual for: php://input
------Solution--------------------
Post is OK?
A lot of ready-made code online

Class Image {
Const ROOT_PATH = './';
Const FAIL_WRITE_DATA = ' FAIL to WRITE DATA ';
No Data flow
Const NO_STREAM_DATA = ' The post DATA is empty ';
The picture type is not correct
Const NOT_CORRECT_TYPE = ' Not a CORRECT image TYPE ';
Cannot create file
Const Can_not_create_file = ' CAN not ' CREATE FILE ';
Upload image Name
Public $image _name;
Picture Save name
Public $save _name;
Picture Save Path
Public $save _dir;
Catalog + Picture Full path
Public $save _fullpath;

/**
* Constructor function
* @param String $save _name Save picture name
* @param String $save _dir Save path name
*/
Public function __construct ($save _name, $save _dir) {
Set_error_handler ($this->error_handler ());

Set Save picture name, if not set, randomly generate a unique file name
$this->save_name = $save _name? $save _name:md5 (Mt_rand (), uniqid ());
Set save picture Path, if not set, use year/month/day format for directory storage
$this->save_dir = $save _dir? Self::root_path. $save _dir:self::root_path. Date (' y/m/d ');

Create a folder
@ $this->create_dir ($this->save_dir);
Set directory + picture full path
$this->save_fullpath = $this->save_dir. '/' . $this->save_name;
}
Compatible with PHP4
Public function image ($save _name) {
$this->__construct ($save _name);
}

Public Function Stream2image ($data) {
Binary Data Flow
$data = file_get_contents (' Php://input ')? file_get_contents (' Php://input '): gzuncompress ($GLOBALS [' http_raw_post_data ']);
The data stream is not empty, then the save operation
if (! empty ($data)) {
Create and write a data stream, and then save the file
if (@ $fp = fopen ($this->save_fullpath, ' w+ ')) {
Fwrite ($fp, $data);
Fclose ($FP);
$baseurl = "http://". $_server ["SERVER_NAME"]. ":" . $_server ["Server_port"]. DirName ($_server ["Script_name"]). '/' . $this->save_name;
if ($this->getimageinfo ($baseurl)) {
Echo $baseurl;
} else {
  • 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.