Skip to main content

Command Palette

Search for a command to run...

How to Upload Files in Google Colab

Updated
2 min readView as Markdown
How to Upload Files in Google Colab
P
PDF Python Hub 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 Our Mission Our mission is simple: To make PDF processing with Python accessible, practical, and enjoyable by teaching real skills that can be applied to everyday automation tasks and professional software development. Whether you're learning for your career, your business, or your own projects, you'll gain the knowledge and confidence to build powerful PDF automation solutions with Python. Learn more: https://payhip.com/PDFPythonHub/blog/news

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.

[Open in Google Colab]


More PDF Python Resources

Want to learn how to open a PDF file?

Check out this mini-guide:

Open Your First PDF with PyMuPDF

More from this blog

P

PDF Python Hub

10 posts

We publish beginner-friendly Python and PDF tutorials, complete learning paths, and Google Colab notebooks.