Fuzen Posted March 21, 2022 Share Posted March 21, 2022 Hey everyone. This community has been of help and I need a little direction. I’m in need of uploading files to a remote FTP server (not at my hosting company). I have to use SFTP and not standard FTP. Can anyone point me in a direction on how to do that within a PW page/app? I have the credentials along with a port number. I’m assuming PW doesn’t have built-in code to facilitate this, correct? So doing research, I found this package:https://phpseclib.com/docs/sftp Assuming I have to use this package, seeing I’m a designer (not developer), could I download the package and simply install it somewhere within PW’s directory structure and then call it from my page? If so, where would I place it? And then once placed, would I call it at the top of my page like so?… use phpseclib3\Net\SFTP; $sftp = new SFTP('localhost'); $sftp->login('username', 'password'); Link to comment Share on other sites More sharing options...
kongondo Posted March 21, 2022 Share Posted March 21, 2022 (edited) 1 hour ago, fuzenco said: Assuming I have to use this package, seeing I’m a designer (not developer), could I download the package and simply install it somewhere within PW’s directory structure and then call it from my page? I'd suggest, no. If you mean uploading files, say one off...then grab a dedicated FTP client (yes, they can do SFTP as well) such as FileZilla or Cyberduck. I suggest you read up on FTP/SFTP, at least the basics, including transfer mode. Also consider whether uploading a zip file and unpacking it is better in your case. You will also need to know about file permissions as you may upload a file only for ProcessWire not to be able to access it due to server file permissions and ownerships :-). If you mean file uploads such as images to a ProcessWire page, then ignore above. Edited March 21, 2022 by kongondo clarification Link to comment Share on other sites More sharing options...
Fuzen Posted March 21, 2022 Author Share Posted March 21, 2022 28 minutes ago, kongondo said: I meant uploading a file from my PW page to a remote server. It has to be part of my app and not something done via an FTP client (in my case Transmit on macOS). Also, file permissions and such I don't have to set. I already have access and permissions based on my login credentials to the remove server. Link to comment Share on other sites More sharing options...
kongondo Posted March 21, 2022 Share Posted March 21, 2022 Aah. I see. In that case, yes, you are right. You will need a 3rd-party or custom PHP solution. I don't think there's currently a module in the Modules' directory to do this. 1 Link to comment Share on other sites More sharing options...
horst Posted March 22, 2022 Share Posted March 22, 2022 (edited) @fuzenco You may also use CURL, or maybe WireHttp, also a wrapper around CURL. BUt not really sure about wireHttp here! Otherwise the phpseclib for sftp is good to go, but maybe a bit to much overhead in this case, compared to CURL, if available? https://everything.curl.dev/usingcurl/scpsftp https://unix.stackexchange.com/questions/56261/automated-sftp-upload-with-curl Edited March 22, 2022 by horst 2 Link to comment Share on other sites More sharing options...
Fuzen Posted March 24, 2022 Author Share Posted March 24, 2022 On 3/22/2022 at 8:47 AM, horst said: @fuzenco You may also use CURL, or maybe WireHttp, also a wrapper around CURL. BUt not really sure about wireHttp here! Otherwise the phpseclib for sftp is good to go, but maybe a bit to much overhead in this case, compared to CURL, if available? https://everything.curl.dev/usingcurl/scpsftp https://unix.stackexchange.com/questions/56261/automated-sftp-upload-with-curl @horst Thank you. I think Curl may do the trick. This will give me something to learn. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now