This question already has answers here:
PHP Parallel curl requests
(3 answers)
php get all the images from url which width and height >=200 more quicker
(4 answers)
Closed 9 years ago.
Im working on script that integrates online shops.
I have code like this (simplified):
// $asImageurls - array of string with image url's
foreach($asImageurls as $sImageUrl)
{
$imageContent = #file_get_contents($image);
// create filename, save image etc.
}
Connecting with remote server, downloading image takes a lot of time, and this is not good when I have like 500 products to import.
I was thinking about some parallel downloading, but I don't know how to start.
What can I do, to make it faster?
There are two main solutions to this problem:
1) Instead of downloading your images directly, store all urls in a file (also eventually the destination path). Then, use cron to call a script every n minutes that will do the downloads for you. This is the best way to avoid server overload if a lot of people submit downloads at the same time.
2) Use the exec() PHP function. This way you could call every system command you want. Typically curl in your case. This way you can add & at the end to throw it in background. You can even store warnings and errors redirecting them to a file.
Related
This question already has answers here:
Change the maximum upload file size
(24 answers)
Closed 6 years ago.
I was wondering if jQuery uploading (via Ajax) has a size limit ? With more details : i'm building a form to upload multiple images on the server (for now, it's in local using wampserver).
Fact is, I can upload one, two or three images easily, but all the next ones do not work : it's like my php function does not receive any information (while the image is treated by jQuery).
I did the test with a lot of images, each time different ones, and the first two or three of them are uploading, but the others are not.
By the way, my jquery function treats each file one by one : once a file is treated, the next one's treatment starts.
There is no limit on the size of the upload files when using ajax. For example, in youtube or facebook (which use ajax to upload files) you can upload whatever you want without any restriction on the size of the uploaded files.
The reason that made your website fail when uploading large files is that you may not set the size of maximum upload files. Check this question, it may help you.
This question already has answers here:
How do you parse and process HTML/XML in PHP?
(31 answers)
Closed 7 years ago.
I would like to implement a PHP web page that, given a certain URL, is going to sniff some images from that page.
Do to so, I need :
1) to access the html source-code of that page and find out the URLs of the images I want.
2) to download these images on my FTP
I don't know how to do these two tasks, I guess I will have to use third party libraries, but this is the first time I need to do so and I am not sure.
Any advices ?
Thank you.
This is actually quite a simple task in PHP:
Use file_get_contents() to fetch the HTML from any random page (cURL would work too).
Using DOMDocument, find all img tags inside the page (see getElementsByTagName() method)
Extract the src attribute from each node.
Download the images somewhere with cURL.
Use the FTP functions to upload them to your server (or use a library like this one).
Did you mean grab html page's images and download them and then upload these images to your own FTP server?
If I catch on you correctly, this task will be completed by plain PHP code, no need of third party libraries.
Use preg_match_all to match all images out
Download them(use curl or file_get_content)
upload them to your FTP server, you can simply use curl again, put that image you downloaded above(you don't need save image in your PHP located machine, it is a File Stream in memory) in POST request body then send the request. Or upload image using FTP related functions(find that function in PHP net Document)
You need do step 2 and 3 in a loop basing on data generated from step 1.
Tell me if you need help about them.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to save webpage as a image file using PHP?
I would like to create an image on the server using a url string that is given.
I want a screen shot of a website to be created.
Is it possible with PHP GD , if so how ?
Thanks
You need something like PhantomJS to do it. This can be called from PHP.
Pretty sure GD can't handle this by itself. You'd need an HTML renderer too.
As far as I know, there is no existing PHP-Lib, which can do this. PHP-GD has to do with graphics, but you cant do this with it. Even if: What will happen, if the Site uses Javascript to enable certain important parts of a site? Or even images or other resources, that require long running requests? Or consider sites using flash... There are some tools for linux to take screenshots in batch - configurable with timer etc.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Combine/Concatenate MP3s on Server Using PHP
I would like to create a 30 minutes mp3 by combining about 1000 small mp3s together.
Is that kind of thing doable using PHP or the ressources usage would be too costly in CPU/bandwidth?
For example, I would like "Ronaldhino dekes player X and is on the run! Great kick! etc."
There is an library called getID3. It has the ability to join multiple MP3 files into one , although I have never used this functionality. There is an demo available at the Source Forge site of getID3 here http://getid3.sourceforge.net/source/demo.joinmp3.phps. It seems that it works around without using any command line system calls.
I have used this library for getting lengths and other data from various media formats. It worked like a charm. However, as said, I have not tested the CombineMultipleMP3sTo() function in it...
You should test this as if it would work for you it would be a far easier option than LAME (which is powerful yet rather complicated to use in my opinion).
This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Upload Progress Bar in PHP
guys, i need some help with this problem
I'm doing a file upload process where the source file is transfered to the server and then the data from it is inserted in to database.
i need to display progress bar which shows the progress from the time of file uploading to server till data inserted into the database from that uploaded file.
i find files uploading progress bar only for files uploading to server and progress bar not till data insertion.
thanks in advance !
Okay, so to write a progress bar you need to know what 100% of the file-size are. To know the file-size on server-side (with PHP which runs server-side), you first have to receive the whole file. But after receiving the file, it doesn't help you anymore, because then the upload would be finished.
Progress-Bars on file-uploads are often done with Flash, as you can detect the file-size client-side with ActionScript (Flash's scripting language).
You can't do that with PHP. PHP is server side language. Better way to do that is to use a jquery and animate it.
There is no way to do this with PHP. I'd use Uploadify.
To measure the progress of the SQL queryes, you can do the following:
After uploading the file you can run some regexp on it to detrmine how many queries you'll have to run
You can then register a counter in SESSION or similar where you know how many queries you have run
Have an AJAX script call a PHP script that gives you the total number of queries and how many of them were executed.
There are some problems though. I don't know what kind of data format you have for the file, so I presumed that it's something that can be transformed in queries. Also, it might be faster run a single query instead of hundreads (for INSERT for example)