hi, I am trying to upload picture using PHP. I made this title because if the thread contains title with tough problem, no one even open thread and try to help.

Actualy i have problem in picture uploading, but critic part is that my code is at one site and i want to upload file on other site, for this i tried to give absolute path to the directory where i want to upload, and full rights to that directory too. But I am not successful. Now please help me out how can i uplaod a file on other domain have code at different domain.

Thanks in advance.

Recommended Answers

All 8 Replies

I suspect that you will need to use FTP. I could be wrong but I don't think that you will be able to do a cross-domain upload of a file the way you would on a single site.

hi, I am trying to upload picture using PHP. I made this title because if the thread contains title with tough problem, no one even open thread and try to help.

Actualy i have problem in picture uploading, but critic part is that my code is at one site and i want to upload file on other site, for this i tried to give absolute path to the directory where i want to upload, and full rights to that directory too. But I am not successful. Now please help me out how can i uplaod a file on other domain have code at different domain.

Thanks in advance.

Please Help me...

I made this title because if the thread contains title with tough problem, no one even open thread and try to help.

Definitely not true and if that has been your experiences in the past with daniweb then that's simply ridiculous. However, onto your question.

The only theoretical (I stress that because I'm only just now contemplating it) way to do that would be to use some kind of automated submission so that when you submit the file to one site, it loads the page with all necessary information and resubmits it over to your other one. But this methods requires php or some kind of server side language that can manipulate files for the image storing end.

In essence, javascript is probably your best bet here as php is limited to the server it's hosted on and cannot access another's. It would make security an absolute nightmare if servers could manipulate each others files.

If you don't mind my asking, why are you trying to accomplish this?

Actually i have four different sites, and i had build same admin for all those 4 sites, now when user add record it goes to thier respective databases via remote database access, but in some cases like when i am storing company information, i need to upload company logo too. In that case i need to upload logo at their respective folders located their own domains.

I hope you understnad what i mean.

Thanks for your reply

Well if that's the case then use cron or a cron equivalent that runs once every say 2-3 minutes. This way "it may take time to update across the server." What you could do for your cron is what I described, make a script that "ques" up all requested logo's that need to be distributed and have the cron script "submit" the information to a "listener" file on the receiving end that would take it and process it all.

But again, this listener file would be vulnerable to attacks. Though, again theoretically, it is possible to do this if you have access to server side code on all the sites you are manipulating.

Thanks for reply Nyight.... One of my friend suggest PHP FTP Library Usage to transfer files. Now i am looking at it, may be i found my solution over their.

Thanks

You need these:
1. you can control the second server
2. CURL

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.