ThinkPHP modification Problems

Source: Internet
Author: User
{Code ...}
$ Id = $ _ GET ['id']; $ data = $ _ POST; $ data ['dateandtime'] = date ("Y-m-d H: I: s "); $ data ['content'] = str_ireplace ('\"', '"', $ _ POST ['content']); $ images = $ _ FILES ['images']; if (strlen ($ images ["name"])> 0) {$ rs = $ news-> field ("images")-> where ("id = ". $ id)-> find (); if (is_file ($ rs ["images"]) {unlink ($ rs ["images"]);} $ data ['images'] = $ this-> upFuns1 ($ images);} else {$ rs = $ news-> field ("images ") -> where ("id = ". $ id)-> find (); $ Data ['images'] = $ rs ["images"];} $ result = $ news-> where ("id = ". $ id)-> save ($ data); $ url =/index. php/Article. "/index"; $ str = "modify"; $ this-> jump ($ result, $ url, $ str ); where if (is_file ($ rs ["images"]) {unlink ($ rs ["images"]);} What does this code mean? Why?

Reply content:
$ Id = $ _ GET ['id']; $ data = $ _ POST; $ data ['dateandtime'] = date ("Y-m-d H: I: s "); $ data ['content'] = str_ireplace ('\"', '"', $ _ POST ['content']); $ images = $ _ FILES ['images']; if (strlen ($ images ["name"])> 0) {$ rs = $ news-> field ("images")-> where ("id = ". $ id)-> find (); if (is_file ($ rs ["images"]) {unlink ($ rs ["images"]);} $ data ['images'] = $ this-> upFuns1 ($ images);} else {$ rs = $ news-> field ("images ") -> where ("id = ". $ id)-> find (); $ Data ['images'] = $ rs ["images"];} $ result = $ news-> where ("id = ". $ id)-> save ($ data); $ url =/index. php/Article. "/index"; $ str = "modify"; $ this-> jump ($ result, $ url, $ str ); where if (is_file ($ rs ["images"]) {unlink ($ rs ["images"]);} What does this code mean? Why?

Update the image. First, determine whether the news has an image. is_file is used to determine whether the file exists. true indicates if.
Unlink is used to delete old images.

Determine whether a file with the same name exists on the server. If yes, delete the file and upload the new file.

Query whether an image value exists by id. If the current image value exists, delete it first, and then update the new image value.

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.