Drupal: How To Copy Files To A Server
Problem: It is necessary to copy (upload) file or files to a server.
Solutions:
- Use FTP
- Use SCP
- Copy via SSH
- File manager in hosting control panel
Use FTP
You need FTP client to connect to FTP-server. There are many FTP-clients, they have different interfaces, additional abilities and licenses.
Attention! It is dangerous to save passwords in FTP-client which saves them opened. If your computer will be infected, the passwords can be stolen and sites – hacked. Use software that encrypts passwords and/or use antivirus.
You need the following data to connect to FTP-server:
- IP-address or FTP server domain name
- Username
- Password
- Port (it is necessary to enter port if it is non-standard, i.e. differs from 21)
Use SCP
scp command allows copying of files through SSH-connection. You can use scp command:
- for copying from a remote server to a local PC,
Attention! point at the end means that files will be sopied to current local folder.
- for copying from a local PC to a remote server,
$ scp file user@server-name:/path/to/folder/on/server/
Copying of all subfolders:
$ scp –r local-folder user@server-name:/path/to/folder/on/server/
Uploading of a few files and folders:
$ scp -r folder1/* folder2 folder3/*php user@server-name:/path/to/folder/on/server/
- For copying from one remote server to other remote server. In this case data are passed directly between servers.
$ scp user1@server-name1:/path/to/folder/on/server1 user2@server-name2:/path/to/folder/on/server2
Copying through SSH
Upload local archive to “path-on-server” folder on “server-name” server:
$ cat ./drupal.tar.gz | ssh user@server-name -pport “cat > /path-on-server/drupal.tar.gz”
Compress fo;es and upload them to server:
$ tar czf – /local-path/copied-files| ssh user@server-name “cat > /pah-on-server/data.tgz”
File manager in hosting control panel
If there is one file, or file is small or there are a few files, and you don’t satisfied with previous solutions, you can user file manager. Usually hosting control panel has it. When creating a web-interface file, a file is created in the name of web-server and web-server is is their owner. This means that you can meet problems deleting these files (but they can be renamed/moved).
Different hostings use different software so there would be different file managers.
The main principle of this method is the following:
- Open hosting control panel in your browser (hosters should give you this address)
- Login to panel.
- Open file manager.
- Navigate to required folder.
- Create a file with required name.
- Open local files that contains content you wish to put on a server.
- Copy content from local file to clipboard.
- Open the created file on server.
- Paste data from clipboard.
- Save file changes on server.
- Verify.
Pay attention to encoding!
Copy by means of Drupal
If Drupal is installed, Upload module is enabled and you have permissions to attach files to articles, you can upload a file using a form of files attaching when node creating. The file will be located in a folder set on “File system” page (admin/settings/file-system).
Then you can move it via SSH or with the help of FTP-client.