Current location: Hot Scripts Forums » Programming Languages » PHP » Output File to windows machine


Output File to windows machine

Reply
  #1 (permalink)  
Old 01-16-07, 10:50 AM
tobyjoiner tobyjoiner is offline
Newbie Coder
 
Join Date: Nov 2006
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Output File to windows machine

is this a permission issue? if so is there a way to add a username and password?

PHP Code:

$filename "\\\\server1\\tobyworkspace\\Test Document Library\\test.txt"
$mystring fopen($filename"w"); 
$test fwrite($mystring"Test"); 
fclose($mystring); 
Code:
Warning: fopen(\\server1\tobyworkspace\Test Document Library\test.txt) [function.fopen]: failed to open stream: Permission denied in C:\Program Files\xampp\htdocs\copytest.php on line 3

Last edited by tobyjoiner; 01-16-07 at 11:01 AM.
Reply With Quote
  #2 (permalink)  
Old 01-16-07, 09:14 PM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
This is what you have written: $filename = "\\\\server1\\tobyworkspace\\Test Document Library\\test.txt"; ... Try this instead: $filename = "/server1/tobyworkspace/Test Document Library/test.txt";
__________________
Jerry Broughton
Reply With Quote
  #3 (permalink)  
Old 01-16-07, 10:28 PM
tobyjoiner tobyjoiner is offline
Newbie Coder
 
Join Date: Nov 2006
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
is that going to work? the file is on a windows server
Reply With Quote
  #4 (permalink)  
Old 01-16-07, 10:54 PM
hen3rz's Avatar
hen3rz hen3rz is offline
Newbie Coder
 
Join Date: Jun 2005
Location: Australia
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
is that going to work? the file is on a windows server
It's my belief that php can only work within its web directory and any files located outside of that are unaccessible. Then again i could be wrong.

To edit files out side of the web directory structure you'll have to use perl.
__________________
Foinq.com - Free Unlimited Web Hosting
Reply With Quote
  #5 (permalink)  
Old 01-16-07, 11:40 PM
Grabber's Avatar
Grabber Grabber is offline
Newbie Coder
 
Join Date: Apr 2006
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
you can use php-cURL to access any file remotely and then edit it though your script must need permission for this so keep your txt file chmod 777
Reply With Quote
  #6 (permalink)  
Old 01-17-07, 12:41 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
This line: $filename = "/server1/tobyworkspace/Test Document Library/test.txt"; tells me that there is a file named test.txt in a folder called /server1/tobyworkspace/Test Document Library/ that resides in your web space. If this location "/server1/tobyworkspace/Test Document Library/test.txt exists somewhere other than your web space then you must specify the full URL like:
Http://someURL.com/server1/tobyworkspace/Test Document Library/test.txt.
Do you understand?
__________________
Jerry Broughton
Reply With Quote
  #7 (permalink)  
Old 01-17-07, 03:48 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
Quote:
Originally Posted by hen3rz
It's my belief that php can only work within its web directory and any files located outside of that are unaccessible. Then again i could be wrong.
php can work with files outside the server root, i just tested it

as far as i know, windows dosn't have permissions, owners or groups. Could you post your folder structure? that would make it a little easier.

UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #8 (permalink)  
Old 01-17-07, 05:48 AM
Vicious's Avatar
Vicious Vicious is offline
Community VIP
 
Join Date: Jan 2007
Location: Belgium
Posts: 584
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by UnrealEd
php can work with files outside the server root, i just tested it

as far as i know, windows dosn't have permissions, owners or groups. Could you post your folder structure? that would make it a little easier.

UnrealEd
Actually, the PHP pages on a windows server are executed by a special IIS account, with limited rights. You have to give that IIS account specific access to a folder outside of the www-root.
__________________
Jack Bauer makes Chuck Norris cry
Reply With Quote
  #9 (permalink)  
Old 01-17-07, 07:21 PM
tobyjoiner tobyjoiner is offline
Newbie Coder
 
Join Date: Nov 2006
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Yeah, I just went a whole other way. The files were not only on a windows server, but were controlled by sharepoint, so they were double crap.

Quote:
This line: $filename = "/server1/tobyworkspace/Test Document Library/test.txt"; tells me that there is a file named test.txt in a folder called /server1/tobyworkspace/Test Document Library/ that resides in your web space. If this location "/server1/tobyworkspace/Test Document Library/test.txt exists somewhere other than your web space then you must specify the full URL like:
I never said that was the path to the server. I said it was \\server1\ which is the windows server, but no matter either way cause I dont want to mess with sharepoint and its MSSQL file storage crap.

Thanks to everyone that posted.
Reply With Quote
  #10 (permalink)  
Old 01-18-07, 02:31 AM
Vicious's Avatar
Vicious Vicious is offline
Community VIP
 
Join Date: Jan 2007
Location: Belgium
Posts: 584
Thanks: 0
Thanked 0 Times in 0 Posts
If you mess a bit with Sharepoint, you can easily see where you have to insert information in the MSSQL database so to not screw up things. But I'm afraid I don't remember exactly which tables they were. A couple of years back, I did some integration between a corporate intranet and Sharepoint. Worked well, so it's not impossible
__________________
Jack Bauer makes Chuck Norris cry
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with my largest perl script. Grabbing data from a file. Sunnmann Perl 2 04-23-08 03:27 AM
Generate HTML output with PHP and mySQL zoliky PHP 3 10-03-06 05:26 AM
Count requesters from an apache log file ddolddolee82 Perl 1 03-17-06 03:08 AM
How Can I output Flash Using Javascript in a PHP file? BrandonB PHP 0 10-18-05 11:35 PM
Upload .xls file from client's machine to SQL Server table bubberz ASP.NET 0 08-09-05 02:40 PM


All times are GMT -5. The time now is 05:52 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.