The following code lets you upload one or more files from your computer directly into a Google Colab notebook:

How it works
1. Import the file-upload tool

This imports Colab’s files module, which provides functions for uploading and downloading files in Google Colab.
2. Open the upload window

When this line runs, Colab displays a Choose Files button. You can select one or more files from your computer.
The uploaded file(s) are stored in the uploaded variable as a dictionary.
For example, if you select a PDF, Colab uploads it to the notebook environment and stores its information in the uploaded variable.
3. Check the filename(s)

Complete Example

Open the notebook
Open the Google Colab notebook for this PDF mini-guide and run the code as you follow along.
Ready to put this into practice? Check out the Python and PDF resources in our store.
More PDF Python Resources
Want to learn how to open a PDF file?
Check out this mini-guide: Open Your First PDF with PyMuPDF.
Comments ()