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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

file handling issues using absolute URLs, for example using unlink()

Status
Not open for further replies.

pushyr

Programmer
Jul 2, 2007
159
GB
i've tried searching the forum and googling this but no joy...

i'm trying to upload and manage images remotely.. the CMS i'd created is on one server and the site is on a different server.

i've whitlisted my IP with mysql remote and the server firewall and i have a mysql connection so everything is good. next thing i did was modify the folders i wanted to upload images to... to 777

but what i can't do is use php file handling functions with full urls.

so i did an experiment... on my local server i did a unlink() on a file using a relative path... worked fine... then i did the same thing still on my local server using it's absolute url... this did not work.

the error i get is...

Warning: unlink() [function.unlink]: http does not allow unlinking in /home/directory/home_html/_files/test/test.php on line 10

how would i go about trying to solve this?
 
you cannot use file handling functions over http.

you could mount the remote file system as a local drive (if it supports such things). If ssh is available on the remote machine you could install the ssh file system that is part of fuse (assuming this is installable on your environment). In either of these scenarios, file handling functions will work OK as the underlying OS handles the connections.

If this is impossible then you will need to build a web services API on the remote machine to take file system commands remotely (use SSL for obvious reasons). This kind of url works ok for a php based web service.

Code:
[URL unfurl="true"]https://myremotesite.com/myApi.php?action=delete&fileID=xxxx&myUserName=yyyyy&myPassword=AAAAA[/URL]
 
hey jpadie

ok everything made sense to me apart from the second paragraph. SSH is not something that i've really worked with hence i was unable to fully understand. but i do know that the remote server does have SSH as i've seen it in cpanel.

the 3rd paragraph was easier for me to understand. so simply i send info (originating from a SSL URL) to a script on the server as opposed to trying to upload and manage images directly into it's directories. i hadn't thought of that one! question is... do you think the script would allow me to upload an image?

 
sure. the script will allow you to do whatever you want. If you are going to upload an image you need to do some preparatory work in manipulating the image and converting it to url-encoded data. then send the image by a curl post.

ssh is secure shell. there are methods of using an ssh remotely attached computer as a mounted disk drive. it's not fast. but it does work.
 
ok cheers jpadie... i'll get working on the solution!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top