Jump to content

fopen() subdomain directory


astralaaron

Recommended Posts

I have a folder in my website root called subdomains, it holds the folders for some subdomains on my website for different locations.. for example http://canada.mysite.com http://america.mysite.com/ etc on the main www.mysite.com there is a control panel page where a user can publish something to a location... my problem is that I am trying to (from the www.mysite.com)fopen() a new file at http://somelocation.mysite.com by doing something like

$file_path = '/subdomains/location/folder/filename.html';$new_file = fopen($file_path,'w') or die("can't open file");

is this against the rules? I can't get it to open the file, do I need to find a different approach or can it be done?

Link to comment
Share on other sites

this is no big deal I figured out a different way to get the result I wanted.. still a bit curious if it is possible or not though EDIT: it is kind of a big deal after I thought more about it, since this has to do with the most common task on my site and my work around includes an extra database call

Link to comment
Share on other sites

it is possible. you make sure that path is correct and that file has permission to write on it.you can check fopen() return value it is successing or not. it would show you some error if error showing is enabled.

Link to comment
Share on other sites

I am getting this error: "failed to open stream: No such file or directory" I can't figure out how to path it correctly. my folder setup is like this

public_html |				   |  mywebsite|				   | 				 | index.php  |				   | 				 | system	|   functions.php				  | 				  |profile  |   publish.php								  | 		  |							   | subdomains|	canada  - (canada.mywebsite.com) 

profile/publish.php includes the functions file and then attempts to write to canada.mywebsite.com I am trying paths like: /subdomains/canada/testfile.php: ./subdomains/canada/testfile.php: ftp://username:passw...da/testfile.php I saw this path in the error when it said no file found at this location: /home1/USERNAME/public_html/MYWEBSITE/system/functions.php so I also tried as a path:/home1/USERNAME/public_html/MYWEBSITE/subdomains/canada/testfile.php I tried also with HTTP:and of course : HTTP wrapper does not support writeable connections Permissions on all of the folders are 755

	  //I tested in Read mode so I can make sure with a direct http path the file exists..//$fpath = 'http://location.mysite.com/testopen.php'; //works	   //$fpath = 'http://www.mysite.com/subdomains/location/testopen.php'; //works	   //$fpath = '/subdomains/location/testopen.php'; //fails	   //$fpath = './subdomains/location/testopen.php'; //fails	   //$fpath = '../subdomains/location/testopen.php'; //fails

I am testing from

http://www.mysite.com/testing/test-publish.php

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...