Seek source code

Source: Internet
Author: User
Which great God has the source code to add personal information and save it in the database, can you send me a copy?
Shao_dmhwl@163.com


Reply to discussion (solution)

I'll give you an upload class. Call Upfile () directly after new, note that the file is to be base64, and then call GetFileInfo () to get the information to save the file format you can expand it yourself under this only support JPG

  "File size exceeds post_max_size limit", "size" = "File size exceeds site limit", "type" = "file type not allowed", "DIR" + "Directory creation lost    "," "IO" = "Input and output error", "UNKNOWN" = "Unknown Error", "MOVE" = "Error in file Save"); /** * constructor * @param string $fileField form name * @param array $config configuration item * @param bool $base 64 parsing base64 encoding , can be omitted.        If on, $filefield represents the Base64 encoded string table sole name */Public function __construct ($fileField, $config, $base = False) {        $this->filefield = $fileField;        $this->config = $config;        $this->stateinfo = $this->statemap[0];    $this->upfile ($base 64);        /** * Main processing method for uploading files * @param $base * @return Mixed */Private function Upfile ($base 64) {            Handle Base64 Upload if ("base64" = = $base) {$content = $_post[$this->filefield];            $this->base64toimage ($content);        Return }//Handling normal upload $file = $this->file = $_files[$this->filefield];            if (! $file) {$this->stateinfo = $this->getstateinfo (' POST ');        Return            } if ($this->file[' ERROR ']) {$this->stateinfo = $this->getstateinfo ($file [' Error ']);        Return } if (!is_uploaded_file ($file [' tmp_name '])) {$this->stateinfo = $this->getstateinfo ("Unkno            WN ");        Return        } $this->oriname = $file [' name '];        $this->filesize = $file [' Size '];        $this->filetype = $this->getfileext ();            if (! $this->checksize ()) {$this->stateinfo = $this->getstateinfo ("SIZE");        Return            } if (! $this->checktype ()) {$this->stateinfo = $this->getstateinfo ("TYPE");        Return            } if ($this->stateinfo = = $this->statemap[0]) {$ret = \biz\common::savepic ($file ["Tmp_name"]); $this->savenAme = \biz\common::getpicurl ($ret);            if (! $ret) {$this->stateinfo = $this->getstateinfo ("MOVE"); }}}/** * Processing base64 encoded image upload * @param $base 64Data * @return Mixed */Private function Base6        4ToImage ($base 64Data) {$img = Base64_decode ($base 64Data); $this->filename = time (). RAND (1, 10000).        ". png"; $this->fullname = $this->getfolder (). '/' .        $this->filename;            if (!file_put_contents ($this->fullname, $img)) {$this->stateinfo = $this->getstateinfo ("IO");        Return        } $this->oriname = "";        $this->filesize = strlen ($img);    $this->filetype = ". png";            /** * Get information about the current upload success file * @return Array */Public function GetFileInfo () {return Array ( "Originalname" = $this->oriname, "name" and "= $this->filename," url "+ $this-& Gt;savename, "size" = = $this->filesize, "type" = = $this->filetype, "state" =    $this->stateinfo);        }/** * Upload error Check * @param $errCode * @return String */Private Function Getstateinfo ($errCode) { Return! $this->statemap[$errCode]?    $this->statemap["UNKNOWN"]: $this->statemap[$errCode]; }/** * Rename file * @return String */Private Function GetName () {return MD5 (time (). Rand (1,10000) . $this->file["name"]).    JPG '; }/** * File type detection * @return BOOL */Private Function Checktype () {return In_array ($this->get    Fileext (), $this->config["Allowfiles"]); }/** * File size detection * @return BOOL */Private Function checksize () {return $this->filesize &lt    ; = ($this->config["maxSize"] * 1024); }/** * Get file extension * @return String */Private Function Getfileext () {return Strtolower (STRRCHR ($this->file["name"], '. '));  }}
  • 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.