Hello,
I'm sorry, my English is bad
My example links_data.txt
http://www.ciceksehri.com/wp-content/uploads/2011/03/5888cicek6.jpg
http://www.hediyecicek.com.stabilisim.com/r/buyuk_urun_resimi/3222.jpg
http://www.ciceksehri.com/wp-content/uploads/2011/03/cicek_0011.jpg
http://www.ciceksehri.com/wp-content/uploads/2010/11/kirmizi-pueskuellue-cicek-resmi.jpg
http://www.cicekresimleri.org/data/media/72/masaustucicekresimleri3.jpg
http://www.baylar.net/cicek_resimleri/cicekresimleri13.jpg
This is my codes
<?php
function readUrls()
{
// Reads links from a file
$read_dir="./";
$read_file="links_data.txt";
$connect_to_red=@fopen ("$read_dir/$read_file",'r');
if(!$connect_to_red)
{
echo "could not open database";
exit();
}
while(!feof($connect_to_red))
{
$read=fgets($connect_to_red,1024);
$url[] = $read;
}
@fclose($connect_to_red);
return $url;
}
function makeFolders($url)
{
// Creates folders of Links
if(is_array($url) && !empty($url))
foreach($url as $url_new)
{
$path = explode('/',dirname($url_new),4);
$dirspath = array('./'.$path[count($path)-1].'/');
$dirspath2 = array($path[count($path)-1]);
for($i=0;$i<count($dirspath);$i++)
{
$fullDir = $dirspath[$i];
exec("mkdir -p ".$fullDir);
$dirs=explode("/",$fullDir);
$currentFolder='';
for($x=0;$x<count($dirs);$x++)
{
$currentFolder.=$dirs[$x].'/';
if(!is_dir($currentFolder))
{
echo "Created: $currentFolder <br/>";
if(!mkdir($currentFolder))
{
die("Could not make ".$currentFolder);
}
}
}
}
}
}
function moveLinks($url)
{
// Moved files of Links
echo '<ol>';
$record_directory = './test_folder/';
for($i=0;$i<count($url)-1;$i++)
{
$file_name = basename($url[$i]);
if(copy($url[$i],$record_directory.$file_name))
{
echo '<li><b>File Uploaded:</b> ';
echo $file_name;
echo '<br /></li>';
}
else
{
echo '<li>error</li>';
}
}
echo '</ol>';
}
$urls = readUrls();
makeFolders($urls);
moveLinks($urls);
?>
Problem this see: http://d1209.hizliresim.com/11/t/dcksp.png
Please help
Thanks