0

I am copying from web and paste html data using editable text area. copy content is any html copy from web can contain img or any text. I want my editable text area to be able to save copy image link.

how to make every img in my editable text area form string to be saved(copy) to my server and change every img src to my new location in my server.?

example copy data :

<h3>Hello</h3>
<img src="http://web.com/img.jpg"><p>Iam want copying image</p>
<p>all image in this is going to be copy</p><img src="http://web.com/img2.jpg">

I want the image in the copy above to saved to my server and renamed, I know how to save it with use file_get_content and file_put_cotent.

so I saved the image have new location

example result string with new location

<h3>Hello</h3>
<img src="http://myserver.com/img.jpg"><p>Iam want copying image</p>
<p>all image in this is going to be copy</p><img src="http://myserver.com/img2.jpg">

and when i put upload the image. thanks

Rons
  • 11
  • 2
  • Search about `DOMDocument`, the methods `getElementsByTagName`, `getAttribute` and eventually the function `parse_url`. Regex is not the way to go. – Casimir et Hippolyte Feb 28 '16 at 00:17
  • as @CasimiretHippolyte mention I successfully do change and upload. using DOMDocument but sometime get error DOMDocument::loadHTML error , and found [this](http://stackoverflow.com/questions/9149180/domdocumentloadhtml-error) to suppress the error – Rons Feb 28 '16 at 03:01

0 Answers0