Unable to upload local files to google colab- file upload does not respond

Viewed 2406

I am new to google collab. I have imported a jupyter notebook from github but cannot upload files from my local machine. I have tried file upload button and the python code

from google.colab import files
uploaded = files.upload()

and neither of them respond. Did anyone have the same problem?

2 Answers

Simply put, you just need to press the button in the red circle and upload what you need. enter image description here

There are two ways to upload files in colab.

  1. Using Code:-

=> Copy This code from Below :

# import and Create new folder
import os
from google.colab import files
import shutil

new_folder = ‘New_Folder’

if os.path.isdir(new_folder):
  shutil.rmtree(new_folder)

os.mkdir(new_folder)

# Upload Files
uploaded = files.upload()
for filename in uploaded.keys():
  dst_path = os.path.join(new_folder, filename)
  print(f'move {filename} to {dst_path}')
  shutil.move(filename, dst_path)
  1. Manually:-

=> Click Show file browser(In Mobile Mode) or Click Folder Icon (In Desktop Mode)

Screenshot 1
Screenshot 2

=> Open ‘content’ folder or other destination. Click 3 dot icon and you will find your options.

=> Now You can create new folder, delete folder, upload files, copy file path etc.

Note : Before trying above steps, Connect to your specific Runtime type.

Related