Page 1 of 1
fwrite
Posted: Sun Aug 05, 2007 5:41 am
by spacebiscuit
Hi,
Does anyone know if it is possible to use the "fwrite" function across to another domain, ie.
Code: Select all
$handle=fopen('http://www.myotherdomain.com/myfile.txt','a+')
When I try this I cam getting an error, any ideas?
Thanks,
Rob.
fwrite
Posted: Sun Aug 05, 2007 6:25 am
by djdon11
i think u should use
function their ... .
may b it works .. i am not sure .. but may be
try this
Posted: Sun Aug 05, 2007 6:50 am
by djdon11
hello
this may wotk hopefully
Code: Select all
$url = 'http://www.yahoo.com';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$returned = curl_exec($ch);
curl_close ($ch);
echo $returned;
Posted: Sun Aug 05, 2007 9:57 am
by spacebiscuit
Thanks for the reply, I tried this but still no success:
$url = '
http://www.mydomain.com/myfile.txt';
Code: Select all
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$url = curl_exec($ch);
curl_close ($ch);
if(!$handle=fopen('$url','a+')){
echo"Handle Error!";
}
Thanks,
Rob.
Posted: Sun Aug 05, 2007 10:07 am
by iknownothing
Im pretty sure you can't write to a file you dont have access to (access to, within your code, that is, obviously you may beable to access FTP).
Posted: Sun Aug 05, 2007 10:33 am
by spacebiscuit
Ok here is some feedback:
It seems that you can access a file on another domain, however I am experiencing some very odd behaviour when doing so, consider this statement:
if(!$handle=fopen('
http://www.mydoamin.com/this_file_does_ ... st.txt','r')){
echo"Error<br>";
}
For the above, the error statment does
NOT rpint to the screen dispite the file not existing, however if I switch the "r" to "a+" it does!
Does not make sense, any ideas guys?
Thanks,
Rob.
Re: fwrite
Posted: Sun Aug 05, 2007 12:21 pm
by John Cartwright
robburne wrote:
Does anyone know if it is possible to use the "fwrite" function across to another domain, ie.
Not possible, you'll need to use the ftp functions.
Posted: Sun Aug 05, 2007 3:06 pm
by spacebiscuit
Thanks for the feedback guys........
I gave the ftp functions a go and after a while but found I was almost pulling my hair out after an hour. Then I realised the problem (I think!) was because although I'm working with files on different domain, the domains are all hosted on the same server! So in effect the local files are in the same location as the remote files and hence the problems!
So..... I then went back to the fopen function and tried this:
$handle=fopen('../myotherdoamincom/myfile.txt','a+'))
So I'm jumping up a directory to the server's root and then acessing the other doamin and its files - seems to be working nicely anyway!
Many thanks,
Rob.
Posted: Sun Aug 05, 2007 5:57 pm
by iknownothing
It's letting you do that?? Not a very secure Host.
Posted: Sun Aug 05, 2007 6:10 pm
by s.dot
iknownothing wrote:It's letting you do that?? Not a very secure Host.
Could be a dedicated server or a virtual server.
Posted: Mon Aug 06, 2007 4:38 am
by spacebiscuit
It is a virtual server the structure is as follows:
usr/home/myusername/websites/mydomain
I can only access the websites that are mine and that are under my username.
Rob.