Pre-requirements
- Access to your cPanel account or SSH for command line usage.
- Basic understanding of file management using cPanel or SFTP.
Important Note on Uploading Folders in cPanel
It is important to note that you cannot upload an entire folder directly through the cPanel File Manager > Upload interface. If you need a folder to be present before uploading files, follow these options:
- Create the new folder first in the File Manager, then upload your files.
- Alternatively, use an SFTP client for file management.
Uploading Files Using cPanel File Manager
If you have successfully created a new web hosting account and logged in to your cPanel account, follow these steps to upload files:
- Scroll to the Files section and click on the File Manager icon.
- Ensure you are in the correct folder or directory by checking the current working directory at the top (e.g., Go Back to “/home/$username/public_html”).
- Click on the Upload option from the toolbar to open the upload interface in a new tab.
- In the upload interface, you can either:
- Drag and drop the files from your local machine into the designated space.
- Or click on the Select File button to choose files manually from your computer.
- If a file with the same name already exists, cPanel will ask you to confirm whether you want to overwrite the file. You can:
- Tick the "Overwrite existing files" option before uploading.
- Or accept the prompt during the upload process to confirm overwriting.
Gotchas to Avoid
- Ensure that the correct directory is selected before uploading files to avoid placing them in the wrong folder.
- Be cautious when overwriting files, as this action cannot be undone.
Uploading Files via Command Line Using SCP
If you prefer using the command line, you can upload files using Secure Copy Protocol (SCP) over SSH. Before proceeding, ensure that your hosting package has SSH access enabled (note: this may not be available for free hosting packages).
1. Upload a Single File
To copy a local file from your machine to your cPanel server:
scp Documents/$project/$filename $username@domain.com:/home/$username/public_html/$filename
2. Upload Multiple Files
To copy multiple files from your local machine to your cPanel server, list the filenames separated by spaces:
scp Documents/$project/$filename1 $filename2 $filename3 $username@domain.com:/home/$username/public_html/
3. Upload an Entire Directory
To upload an entire project folder from your local machine to your cPanel server:
scp -r Documents/$project $username@domain.com:/home/$username/public_html/$project
Gotchas to Avoid
- Always verify that your SSH access is enabled before attempting to use SCP.
- Double-check file paths to ensure files are being uploaded to the correct destination on the server.
Uploading files via cPanel or the command line is a straightforward process. While cPanel File Manager offers a graphical interface for single files, the command line provides more flexibility for uploading folders or multiple files at once. Always ensure you are working in the correct directory and be mindful of overwriting existing files to prevent accidental data loss.
If you want to add to this tutorial or have found an error in it, please send an email to team+editorial@webhostingm.com