thinkphp FTP upload file problem

Source: Internet
Author: User
thinkphp with the FTP upload how to use, I want to upload videos and pictures, but still not, I read the manual, but not very clear, if you can have an example of the best, thank you,


Reply to discussion (solution)

Can be posted you do not understand the place, thinkphp official website has uploaded file use example.

The controller handles the new album module function Album_add () {if (!session ('? user ')) {$this->error (' no permission operation! ', "", 3); } if (is_post) {$upload = new \think\upload ();//Instantiate upload class $upload->maxsize = 3145728 ;//Set attachment upload size $upload->exts = array (' jpg ', ' gif ', ' PNG ', ' jpeg ');//Set attachment upload type $d _root = $_            server[' Document_root ']; $upload->rootpath = $d _root. '/upload/album/'; Set the attachment upload root directory $upload->savepath = ";            Set attachments Upload (sub) directory//upload file $info = $upload->upload ();            $images = "";            $cover _image = "";            $index _cover = "";            if (! $info) {//Upload error message $this->error ($upload->geterror ());                        } else {if (Is_array ($info)) {foreach ($info as $key = = $value) { if (Strpos ($key, "Album_cover_add")!== FALSE) {$cover _image = '/upload/album/'. $value [' Savepath '].                            $value [' Savename ']; $thumb _image_path = '/upload/album/'. $value [' Savepath ']. '                            Admin_cover/';                            $image _name = $value [' Savename '];                            Create_dir ("$d _root. $thumb _image_path");                            $image = new \think\image ();                            $image->open ("$d _root$cover_image"); Generates a thumbnail that is centered trimmed to 150*150 and saved as Thumb.jpg $image->thumb (150,\think\image::image_thumb_center                            )->save ("$d _root$thumb_image_path$image_name"); $admin _cover_path = $thumb _image_path.                        $image _name; } else {$images. = '/upload/album/'. $value [' Savepath ']. $value [' Savename '].                            "|"; $images _path = '/upload/album/'. $value [' Savepath '].                            $value [' Savename ']; $index _cover_path = '/upload/album/'. $value ['Savepath '].                            ' index_cover/';                            $image _name = $value [' Savename '];                            Create_dir ("$d _root. $index _cover_path");                            $image = new \think\image ();                            $image->open ("$d _root$images_path"); Generates a thumbnail that is centered trimmed to 150*150 and saved as Thumb.jpg $image->thumb (150,\think\image::image_thumb_center                            )->save ("$d _root$index_cover_path$image_name"); $index _cover. = $index _cover_path. $image _name.                        "|";            }}}} $nowTime = Date (' y-m-d h:i:s ', Time ());            $a [' title '] = I (' Post.album_title_add ');            $a [' cover_image '] = $admin _cover_path;            $a [' index_cover_image '] = $index _cover;            $a [' images '] = $images;            $a [' add_time '] = $nowTime;            $a [' last_update_time '] = $nowTime;        $album = M ("album");    $album->create ($a);            $result = $album->add (); if ($result) {//Set the address of the jump page after success, the default return page is $_server[' http_referer ') $this->success (' album published successfully! ')            Lbum_list ", 3);            The default jump page for the else {//error page is to return to the previous page, usually without setting $this->error (' album Publishing failed! ', "", 5);        }} else {$this->display ("Album_add"); }} page Template:

Thank you, have solved ~ ~

  • 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.