Post textarea text information to the background, but the background can not be extracted to the image array, solve????

Source: Internet
Author: User
Post Extract Image http

I used Kindeditor to do a textarea online edit box, when the user deleted textarea inside the picture upload another picture, in order to save server space. I extracted the textarea image from the original database to form an array, and then compare each value in the array with the newly passed TextArea In_array (), and the saved picture is deleted. Strange, the new passed over the textarea, but unable to extract the image array, extract the result is an empty array. Please enlighten me, thank you.


Reply to discussion (solution)

When the user deletes the picture inside the textarea
How can you extract the image address from the new textarea?

Specifically, when a user deletes a picture in textarea, such as exp.jpg, submitted to the background, the image array extracted from the $_post[' textarea '] should be less than one value, that is, exp.jpg. This time from the original database textarea extracted image array and background received image array relative, the missing figure on the path is the user in the foreground to delete the image is not deleted in the server.
When the user deletes the picture inside the textarea
How can you extract the image address from the new textarea?

The problem is that, in any case, the image array extracted from $_post[' textarea ' received from the background is empty. But $_post[' textarea ' is really an IMG image. It is strange to save to the database in the extraction is right, directly from the $_post[' textarea ') extract can only be empty.
When the user deletes the picture inside the textarea
How can you extract the image address from the new textarea?

Need to know how you extracted it.
Also need to know the contents of $_post[' textarea ')

Content in the front desk textarea:


Love Micro Amoy is a Professional engaged in mobile application development, API development of the technical team.


Background reception and processing:
$content = isset ($_post[' content ')? $_post[' content ': false; $pic _now = get_pic_html ($content);     Now the picture array print_r ($pic _now);   Always Empty/* * Extract images from HTML to integrate into array @ param string $str @ return array*/function get_pic_html ($str) {   $pattern = "/<[ Img| Img].*?src=[\ ' |\ "] (. *? (?: [\.gif|\.png|\.jpg])) [\ ' |\ '].*? [\/]?>/];    Regular type   preg_match_all ($pattern, $str, $match);     return $match [1];    Returns a one-dimensional array with only a picture path}

Need to know how you extracted it.
Also need to know the contents of $_post[' textarea ')

$s =<<< HTML


Love Micro Amoy is a Professional engaged in mobile application development, API development of the technical team.

Html;function get_pic_html ($str) { $pattern = "/<[img| Img].*?src=[\ ' |\ "] (. *? (?: [\.gif|\.png|\.jpg])) [\ ' |\ '].*? [\/]?>/]; Regular type preg_match_all ($pattern, $str, $match); return $match [1]; Returns a one-dimensional array with only a picture path}print_r (get_pic_html ($s));
Array
(
[0] =/info/201311/1384551494771680415.jpg
)
Your code doesn't have a big problem.

However, Echo base64_encode ($_post[' textarea ') is still required; The results to verify

Background Direct printing only to find that PHP to post the IMG Div span, such as the double-quote tag automatically escaped.
So the picture tag becomes so that the regular validation does not come out.
The post data is stripslashes () and the backslash is OK.
Oddly, the textarea in the database was written without a backslash:

$s =<<< HTML


Love Micro Amoy is a Professional engaged in mobile application development, API development of the technical team.

Html;function get_pic_html ($str) { $pattern = "/<[img| Img].*?src=[\ ' |\ "] (. *? (?: [\.gif|\.png|\.jpg])) [\ ' |\ '].*? [\/]?>/]; Regular type preg_match_all ($pattern, $str, $match); return $match [1]; Returns a one-dimensional array with only a picture path}print_r (get_pic_html ($s));
Array
(
[0] =/info/201311/1384551494771680415.jpg
)
Your code doesn't have a big problem.

However, Echo base64_encode ($_post[' textarea ') is still required; The results to verify

Escaping is convenient for warehousing, escape characters are not retained by the database

  • Related Article

    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.