Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP Check and Copy Files works on C: doesnt on K:

Status
Not open for further replies.

scriggs

IS-IT--Management
Jun 1, 2004
286
GB
I have some code which checks for a file and if exists then loops round with a numeric suffix.

This worked great testing on my local machine using c:\ drive, but now I have moved it my server and am calling a mapped drive called k:\ - all I changed in the code was c:\ to k:\ . Now I get the error:

Warning: copy(K:\IT\Letters\Letter.doc): failed to open stream: No such file or directory in C:\Inetpub\ on line 61

Then the system opens the template file, majes changes and cant't save it as it is read only. I thought maybe its becuase the server is calling a netowkr drive so I gave the server the same mapped drive as the clients.

My code:
Code:
<?php
$outpath = "K:\\IT\\letters\\";
$letter_dir = "K:\\IT\\letters\\";

// (connect to the database)
$odbc_dsn = "timeandfees_db";
$odbc_userid = "";
$odbc_password = "";


//$query = "SELECT ClientKey,CoyName FROM clients WHERE ClientKey like 'AC%' ORDER BY ClientKey ;";
$query = "SELECT * FROM qryclientsData WHERE ClientKey like '" . $_POST['custname'] . "' ORDER BY ClientKey ;";

if(!($odbc_db = odbc_connect($odbc_dsn, $odbc_userid, $odbc_password)))
	die ("Could not connect ot ODBC data source $odbc_dsn");
  
if(!($odbc_rs = odbc_do($odbc_db, $query)))
	die("Error executing query $query");
  
$num_cols = odbc_num_fields($odbc_rs);
if($num_cols < 1) die("Query returned an empty set");

$num = odbc_num_rows($odbc_db,$query);

$path = "K:\\IT\\Letters\\Letter.doc"; 

if( !file_exists( $letter_dir . "Letter.doc" ) ) //if there isn't a $outpath\letter.doc we can just name our output that
{
   $output = $letter_dir . "Letter.doc";
   copy( $path,$output );
}
else //find the next name that we can use, name our output that
{
   $i = 1;
   while( file_exists( $letter_dir . "Letter$i.doc" ) ) $i++;
   $output = $letter_dir . "Letter$i.doc";
   copy( $path,$output );
   echo "<p>Filename is $output</p>";
}
 
Are the networked systems on a domain? Are you running IIS? There are issues with networked drives on IIS. The machines need to be a part of the same domain.

Bastien

I wish my computer would do what I want it to do,
instead of what I tell it to do...
 
Hey Bastien.

Yes, the machines are networked in a domain and running on IIS. I only have a single domain though so they are all part of the same domain.

How about if I use UNC then for my connection? i.e. \\server\letters\letter.doc?

Or any other suggestions?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top