Download all images from a single webpage - php

I'm experimenting with PHP, and I've just asked myself a question. How can I download all images from a single website? Let's say that I wanted and images from cnn.com or any other website. Is there any easy way I can download all the images using PHP, and save them on my local computer (or FTP server).
Any help would be appreciated.

Not very easy, but not that hard:
Request the page using Curl, parse the HTML using DOMXpath and look for the src attributes of the images. Then download the images via Curl by adding the full http address to the image path/name.

If you wanted just all download all images referenced by img elements.
Request the remote file with something like cURL.
Use a DOM parser (such as DOMDocument) to get all img element.
Iterate over the img elements and use cURL (or similar) to download each image (check the src attribute).

Related

how to convert pdf file into html and display them in iframe

I am working on content oriented website and using I frames to display pdf.when I am opening that page in the mobile browser it starts automatically starts downloading the pdf,how could I display pdf file using iframe in browser instead of downloading.
Now i am thinking to convert pdf's into HTML and pass HTML file as source in frame.
Suggest me some other alternative if I'm wrong and if I'm right then suggested me some pdf to HTML convertors,which can convert in bulk as I have very large number of files.
**EDIT:**thanks,it worked but can how can i stop it from being download,i'm thinking of disabling right click,will it work
One thing you can do is to upload your PDF somewhere and just use its URL.
You can also use Google PDF viewer for this purpose.
For more information check this Recommended way to embed PDF in HTML?
There are many ways you can make this possible one of them would be use the following <embed> element with source link to your pdf file :
<embed src="http://example.com/yourfile.pdf" width="1000" height="500" type='application/pdf'>
Another one is you can use the javascript library also :
pdf.js
and one last i have in mind is you can use google docs api url to view the : docx,doc,xls,pdf,ppt or any other document file online by using the method below:
https://docs.google.com/viewer?url=http://example.com/yourfile.pdf

Detect if php script has been requested by <img> parsing

I have a file manager website running and some users said they'd like to be able to embed the image preview page directly into img tags (on forums etc).
Lets take this page as an example: http://push.anukthewolf.com/a/Screenshot_2015-06-03-08-29-03.png
Even though it has an image extension, it's still a html (well, php) page. Could this script somehow detect if its requesting client is a browser parsing an img tag where its url has been used as source?
If that's the case I would output the image directly instead of the website. In every other case, the website should be sent.

Get FLV file URL from a webpage

I want to get FLV file url of the webpage with automation, is it possible? because that site has no autoplay, when i use GetFLV i get the url on when i press play button, i need to get url in php code'automatically, How to do it?
Retrieve the HTML of the page (using a library such as cURL)
Parse the retrieved HTML (using a library such as the PHP DOM)
Extract the relevant URL from the DOM tree
It is possible the URL was generated via JavaScript, in which case you'll also need to run a JS interpreter or close facsimile thereof.
P.S. - remember to check that doing this does not violate the web site's terms of service.

Image Preview using AJAX in PHP

How should i create a preview of image to be uploaded before it is actually submitted using AJAX in PHP?
Without uploading the image, this is going to be impossible in JavaScript as far as I can see, because security limitations are going to prevent you from determining the selected file in the file upload, and embedding that file in an img tag (as it used to be possible five years ago.)
You will be more lucky with Flash-based uploaders. I have seen some that offer the kind of functionality you want.
Update: Here's one that offers a preview function. From what I can see, it base64 encodes the local image and serves it to the surrounding HTML page as a inline data <img> tag. This is great because it might integrate well into your site. It does not work with any version of Internet Explorer, though.
Here's a fully Flash based solution that does previews in all browsers.
you first have to upload the document to server. Than you can show like.
<img src="uploads/file1_12224.jpg" />
The "file" input type doesn't expose the local file location of the file to be uploaded. It does "appear" to because as a user you can see the location, but the web page never knows this value. Without the local file address, you can't show a preview of the image on the web page using plain HTML or JavaScript.

How to put an image url from internet in tcpdf file?

Hi I want to put an image into the PDF file I'm making using TCPDF. It is an image generated by an online API so I cannot store it on my webhost. But when I put the image URL for creating I'm getting error while generating the PDF file.
TCPDF can only use images saved on your webhost - local files, as it needs a physical path to the image in order to include it in the document. The only way you could grab an image from HTTP to be used for TCPDF would be to use cURL, which is something I have only used for text and html, but have no experience grabbing images with, but I'm sure there's a way it can be done.

Categories