-1
<form id="form" name="form" method="post" action="process_image.php">
<textarea name="urls" cols="60" rows="10"></textarea>
<input type="submit" value="Upload Images" />
</form>

What should i add to this code for it to resize the images
automatically with a width:175px and height: auto

    <?PHP
 $urls = $_POST['urls'];
 $list = explode("\n", $urls);


 if (!file_exists("images")) {
  mkdir("images", 0755);
 }

 $files = array();

 foreach ($list as $links) {
  $image = get_image($links);
  $file = 'images/' . img_name($links);
  file_put_contents($file, $image);
  array_push($files, $file);
    }

 function get_image($url) {
   $ch = curl_init();
   $timeout = 5;
   curl_setopt($ch,CURLOPT_URL,$url);
   curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
   curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
   $data = curl_exec($ch);
   curl_close($ch);
   return $data;
 }

 function img_name($url) {
  $chars = array_merge(range(a, z), range(0, 9));
  $extension = get_extension($url);
  $name = "";
  do {
      for($i = 0; $i < 6; $i++) {
          $name .= $chars[rand(0, (count($chars) - 1))];
      }
  } while (file_exists('images/$name.$extension'));
  return $name . "." . $extension;
 }

 function get_extension($url) {
  $ext_pos  = strpos(strrev($url), ".");
  $ext = substr($url, (strlen($url) - $ext_pos), $ext_pos);
  return $ext;
 }

?>

and here it displays the urls:

    <form name="form_process">
 <label>Images Uploaded</label>
 <textarea id="image_urls" cols="50" rows="10"><?PHP
  foreach($files as $uploaded) {
   echo "http://".$_SERVER['HTTP_HOST']. "/" .$uploaded . "\n";
  }
 ?></textarea>
    </form>
Zhianc
  • 1,411
  • 3
  • 20
  • 37

2 Answers2

0

What you exactly need is resizing a image. Well take a look at this post on how to resize a image.

Community
  • 1
  • 1
Jeyanth Kumar
  • 1,589
  • 3
  • 23
  • 48
0

This might be a helpful place to start, even if you decide to roll your own:

Resizing images with PHP