How to Upload Files in Google Colab

The following code lets you upload one or more files from your computer directly into a Google Colab notebook:
from google.colab import files
uploaded = files.upload()
How it works
1. Import the file-upload tool
from google.colab import files
This imports Colab’s files module, which provides functions for uploading and downloading files in Google Colab.
2. Open the upload window
uploaded = files.upload()
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)
uploaded.keys()
Complete Example
from google.colab import files
uploaded = files.upload()
uploaded.keys()
Open the notebook
Open the Google Colab notebook for this PDF mini-guide and run the code as you follow along.
This mini-guide was originally published on PDF Python Hub, where you can find more in-depth Python resources for working with PDFs.
What's Next? Open Your First PDF in Google Colab
Want to learn how to open your first PDF in Google Colab?
Check out this mini-guide:
About the author
- PDF & Python Lab is dedicated to teaching PDF programming, automation, and engineering with Python through practical, project-based courses. Whether you're a complete beginner or an experienced Python developer, the goal is to help you build the skills needed to work with PDF documents confidently—from reading and extracting data to building enterprise document processing and AI-powered workflows. What You'll Learn The curriculum covers every stage of PDF processing, including: -PDF fundamentals -Document extraction -PDF manipulation -Forms, tables, and images -OCR and scanned documents -Security and redaction -Enterprise automation -AI-powered document processing How You'll Learn Every course is designed to be: -Beginner-friendly with clear, step-by-step explanations -Focused on practical, real-world applications -Built around hands-on projects and assessments -Structured as a complete learning path from beginner to expert
Comments
Join the discussionNo comments yet. Be the first to comment.



