Problem copying files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
winsonlee
Forum Commoner
Posts: 76
Joined: Thu Dec 11, 2003 8:49 pm

Problem copying files

Post by winsonlee »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I am trying to copy files from a map directory which is I drive to my local hard disk. But when i tried copying, i got the following error msg. What is the cause of this problem ?


Warning: copy(I:\temp\xxxx.pdf) [function.copy]: failed to open stream: No such file or directory in C:\Program Files\xampp\htdocs\check.php on line 25
failed to copy ...

Code: Select all

$result = mysql_query($sql, $connection);

				 
				while($dbarray = mysql_fetch_array($result)){

          $filename = 'C:/temp/'.trim(strtolower($dbarray[0])).'.pdf';
          $existfilename = 'I:/temp/'.trim(strtolower($dbarray[0])).'.pdf';
          if (file_exists($filename)) {
             echo "The file $filename exists<BR>";
          } else {
     					if (!copy($existfilename, $filename)) {
                 echo "failed to copy $file...\n";
              }

          }

}

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Re: Problem copying files

Post by volka »

If the script runs on another account (e.g. an apache service running as localsystem) it does not have access to the same network mappings as the interactive user.
winsonlee
Forum Commoner
Posts: 76
Joined: Thu Dec 11, 2003 8:49 pm

Post by winsonlee »

Is there any way i can resolve this problem ??
User avatar
waradmin
Forum Contributor
Posts: 240
Joined: Fri Nov 04, 2005 2:57 pm

Post by waradmin »

I believe you can give apache access to different directories, drives, etc. Try http://www.google.com/search?hl=en&sa=X ... es&spell=1 its got some links to get you started im sure.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

winsonlee, please start using syntax highlighting tags.
Post Reply