php - How to define timeout for copy image from server -


i need copy image server in order create different types of images it, e.g. thumbnail.

while works ok imagecreatefromjpeg($picture_location); create problem if image not available , take 30s timeout.

therefore thought downloading first copy:

copy('http://www.server.com/file.jpg', '/tmp/file.jpeg'); 

unfortunatelly there no way decrease timeout if connect fails or image has been removed.

is there better way achieve intending? thank on this.

you can download file via curl has timeout option.

<?php  $fp = fopen (dirname(__file__) . '/localfile.tmp', 'w+'); $ch = curl_init($url); curl_setopt($ch, curlopt_timeout, 50); //timeout curl_setopt($ch, curlopt_file, $fp);  curl_setopt($ch, curlopt_followlocation, true); curl_exec($ch); curl_close($ch); fclose($fp); ?> 

Comments

Popular posts from this blog

html - Difficulties with background-image property -

visual studio code - What does the isShellCommand property actually do and how should you use it? -

ios - Segue not passing data between ViewControllers -