Is there any possbile solutions in PHP to create a file or directory on the client machine.
Note:
Downloading the file is not a solution to me. only once the user access the website and execute some function and it allows to create a files or directory on the client machine.
Simply, you can't do that in php or any other server side language.
Reason is simple server side application and scripts have access only to local resources where they are launched. So when you run your application on local computer, everything works as you wish for. But because of how HTTP works and because of safety reasons you cannot access user local files.
No it's not possible , except- Flash, Applet ( Not sure ), Microsoft Silverlight ! and for those you will also have to give permission. But i don't think it is a good idea to store file on client machine, try another :)
Related
I have access to server of our company's website. I access it using Putty.
I want to download all files(index.php, any jpg files for favicons, etc.) used for deployment of the web project. When I told to programmer of website to share the full script(HTML,CSS,PHP, jquery plugins), he said that I can access the entire code from server.
When I enter the server via Putty(private key+ssh), and then I type "ls" I see that there are "index.php" and "mysql" files, the full contents of which I cannot download.
What are the useful resources for list of commands?
Which command should I use to download the project folder containing all files with code and without code?
P.S. I do not know if this information is necessary, but the website was deployed using DigitalOcean.
As you are using Putty, I'll assume you are working on Windows. There is a GUI tool called WinSCP that works similar to Putty (i.e. over SSH and uses private keys and stuff) and can be used to access the remote server's filesystem. It has a pretty simple to understand UI which will be divided into you local filesystem and the server filesystem. Once you're connected and have reached the files you need you can just drag and drop the files into your local filesystem side.
If you would like to explore some command line options, its basically any tool that does scp. I think Putty comes with scp or pscp installed already. You can check by just typing in the command in your cmd/powershell.
You can download pscp.exe from PuTTY website and then:
Open cmd.exe and type:
pscp your_username_here#yourcompany.com:/path/to/file C:\Path\To\The\New File
I need to create an application using php which is hosted in a server and need to communicate with a csv file located in clients local machine. Is there any way we could do this ? How can I connect to a remote csv file ? Is this possible ?
Server machine accessing a csv file directly from a client machine is not a good idea. It's a security threat indeed. Consider you are navigating some website and it's server is able to access your computer's file system!!!
There are various alternatives to achieve this, some of these might be:
Make the user upload csv files to server in order to make it
available to the server application
If the client and server are in the same network, then share the
folder on client machine to make it accessible from the server
etc... I would have preferred the first option as mentioned above.
As #AnthonyB mentioned in comment under your question, server can't directly call client, and that is true. Server is called "server" as it serves requests from the client.
To be able to give away files to remote requests, your client needs its own server application, like Apache HTTPD for example.
In case if you need continuously request client's server to collect files with your PHP server, what you are looking for called "worker". One of AWS tools called Elastic Beanstalk offers possibility to choose a server or a worker application during start up wizard for PHP. It is pretty straight forward and easy to use.
Please note, that your client must have dedicated IP address or use Dynamic DNS approach by pushing its IP to a DB (or directly to a server) where worker will take it from.
If you don't need dedicated worker, you can configure CRON JOB to send requests to clients server applications.
IMHO, all that scenario worth it only if you are building corporate grade application. In most cases (and if you do REALLY need to collect files from clients) you have to install Apache + PHP server on the client side and make this guys to wait for request from YOUR remote php server. Without it, you can not get files from clients computers via browser without user input interactions. At least legally :)
I want to send a file from my browser to a server which is not the server on which the site is hosted.The problem is the another server is not a web server.
Is it programmatically possible to send a file to different server without the involvement of host server? I do not want copy of the file I am uploading on my hosting server.
Sorry for not being clear on the first go. I hope this makes sense.
Note: I have the IP address of server. Implementation has to be done in a secure way.
Create a signed application to handle the upload.
One of the fundamental rules of browser sandboxing is that you don't let the browser communicate to a server other than the one which provided the website. This has been a rule for quite some time, and is done for security reasons.
The only way I know of to bypass this restriction is to use a signed application. This is possible in several languages including at least Flash and Java. Once you've signed your application with an authoritative source, then you can specify that your application is known to communicate with a third-party server and should be trusted to do so. The process of doing this will be different depending on the technology you choose.
The server to which you are sending the file needs to allow some sort of protocol in order to accept the file. You do not specify what that is, but these languages should be more than sufficient to implement whatever you need.
given that you have the necessary authentication of the secondary server you can
i'll explain using ftp, but there can be other socket related ways
1) upload the file to your server as usual, using $_FILE
2) use the ftp class in php to transfer the file to the remote host
Thanks all for valuable suggestions. I am opting for bit weird way but it seems the only feasible solution considering the current requirements of the project.
I am planning to install lite version of web server and php on the external server which can accept uploaded files through browser.
Our team has worked out this is the best solution we can consider as of now.
Thanks again to all for their suggestions.
This is done all the time with Firefox plugins, (youtube etc.). Does it have to be driven from your page source ? How stealthily do you want to do this ?
The other server should use a common protocol, SSH or ftp or NFS or CIFS.
In any case the user is going to have to agree with the plugin or the applet or a third party service (think punkbuster) running in the background.
BF4 runs in a browser window via a plugin and routinely sends data to servers other than the game server.
I have a client database that generates and stores reports on a local server and I would like these reports to be able to be accessed by a publicly accessible remote server.
The local server runs windows, and I am running a unix installation on the remote server.
The public side is built with codeigniter, and the local side is proprietary php code. How would I go about transferring files onto the remote server?
I am not looking for somebody to write the code for me, but if you could provide a general example, or point me in the right directon it would be greatly appreciated.
You can use CURL to send file in background to local server to other server, Here is good example.
How to send upload file to other website by using curl in php?
I ended up installing winSCP on my local windows server, then from the php file using shell_exec to call a batch file with commands to transfer the file.
I'm not sure how common my request is but here goes:
I have a client who wants to be able to receive files of up to 2GB in size from their customers. The reason why the files are kind of big is because they are graphic design files. Ideally, they would have their customers transfer their files via FTP using an FTP client like Filezilla. However my client has stated that they spend way too much time trying to school people on how to enter FTP credentials into an FTP program and the concept of FTP in general.
So ultimately my client has stated that they would like the customer to be able to use a web interface, which they're already familiar with, to be able to accomplish the same task. For example, they'd like the customer to be able to use a form and hit an upload file button. Simple as that.
At this point I should state that I'm working on a WordPress site on top of a Rackspace Cloud Sites server (shared hosting).
I'm using a WordPress plugin that allows me to do this and it works for small files but not for files approaching 500MB. After speaking to a RS Cloud tech support person I've narrowed it down to the temporary directory /tmp/ in the Apache server. That is the server is not able to write large files into that temporary directory because of their server wide restrictions. That is, they cannot change this to accomodate my needs. They said I would need a dedicated server for that, which, is not an option for me.
After doing some thinking though, I've come to the conclusion that it's silly for me to have to upload a file to the server's temporary directory, only to move the file to the ftp server. So this brings me to my question: is it possible for a web based PHP script to send the file directly from the user's machine, bypass the web server, and send it directly to the FTP server?
If not, do you have any other suggestions? Any help would be appreciated. Thanks.
No, it's not possible at all.
My suggestion? Search and learn how to use HTML5 upload for large files.
Its seams like someone find solution for your problem. Please refer to this question:
Stream FTP download to output
The question was how to stream/pipe file from FTP thru HTTP to the user's browser.
It seams like the answer from #strager is what you need.