0

bellow is my entire file, the problem is when i insert multiple links, it only fatch 1 link from the textarea and then giving me the following error on the rest, FYI there is no problem with the reading part in the text area i can read line by line of the link i insert to the textarea..

Warning: fopen(http://lulzimg.com/i5/bc15e4b0.png ) [function.fopen]: failed to open stream: HTTP request failed! in H:\Developments\www\check.php on line 30
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<form action="check.php" method="post"><textarea name="ta" cols="50" rows="10"></textarea><input name="" type="submit" /></form>

<?php 
if (isset($_POST['ta'])){
$textarea = $_POST['ta'];

$check = explode("\n", trim($textarea));
$lines = count($check);

echo "Lines: $lines";

for ($i = 0; $i < count($check); $i++) {
      echo '  <div>'.$check[$i].'</div>';
	  set_time_limit (24 * 60 * 60);
	  
		 $destination_folder = 'u/';

		$url = $check[$i];
		$newfname = $destination_folder . basename($url);
		
		$file = fopen ($url, "rb");
		if ($file) {
		  $newf = fopen ($newfname, "wb");
		
		  if ($newf)
		  while(!feof($file)) {
			fwrite($newf, fread($file, 1024 * 8 ), 1024 * 8 );
		  }
		}
		
		if ($file) {
		  fclose($file);
		}
		
		if ($newf) {
		  fclose($newf);
		}
		
		echo basename($url);
	
    } }?>
</body>
</html>

Edited by muhamin: n/a

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by paulrajj
0

nvm guy , the problem was with a space in the urls by using a trim in my $url it works now..

$url = trim($check[$i]);
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.