Closed Thread Icon

Preserved Topic: copy() function in PHP (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=18092" title="Pages that link to Preserved Topic: copy() function in PHP (Page 1 of 1)" rel="nofollow" >Preserved Topic: copy() function in PHP <span class="small">(Page 1 of 1)</span>\

 
butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 04-24-2001 04:30

Here's the code Mr. Max helped me work out in another thread. I'm trying to take it one step further and take the images and copy them to another folder. I must be doing something wrong, because I keep getting:

Warning: Unable to create '/Windows/Desktop/upload/md3/main/right_side.gif': No such file or directory in c:\program files\apache group\apache\htdocs\image_finder.php on line 17

I don't know why it won't create the directory. here's the code:

code:
<?
$dir_name = "/Windows/Desktop/server_stuff/HTML/";
$new = "/Windows/Desktop/upload/";
$dir = opendir($dir_name);
$file_list = "<ul>";

while ($file_name = readdir($dir)) {
if (preg_match("/html\$/i", $file_name)) {
$html_file = "$dir_name$file_name";
$f = fopen($html_file,r);
$fd = fread($f, filesize ($html_file));
if (preg_match_all("/<IMG(.+?)SRC=\"?([^\"' >]+)/i", $fd, $arrayofimages)){
foreach ($arrayofimages[2] as $img) {
$img_dir = "$dir_name$img";
$new_copy = "$new$img";
copy ($img_dir, $new_copy);

}
}
}
}

$file_list .= "</ul>";

closedir($dir);
?>



Thanks for your help


[This message has been edited by butcher (edited 04-24-2001).]

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 04-24-2001 21:36

You must create destination folder(s) by yourself. copy() function only copies files (it doesn't create folders).

butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 04-24-2001 21:47

Thanks Mr. Max

kat
Paranoid (IV) Inmate

From: memphis TN
Insane since: Apr 2001

posted posted 04-25-2001 23:13

use mkdir() to make a directory

{ kat ; mmm.. a site! }

« BackwardsOnwards »

Show Forum Drop Down Menu