user17108794
user17108794

Reputation: 111

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

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?

Upvotes: 11

Views: 33545

Answers (6)

sandalwoodsh
sandalwoodsh

Reputation: 235

Um, are you using Google Chrome with Google Collab? I'll give you a hint why it might not be working...Google. Trying using Google Chrome as your browser for Google Collab and I'll bet...ba bam...it suddenly works. Magic. F.A.N.G. wars.

I've come back here (Nov 10, 2024) after posting this a year ago to save everyone time. Try using Google Chrome as your first step; it WILL solve your problem. My point in the previous paragraph was to point out to you that Google wants you to use their product and they will thwart other browsers - it's intentional!

Upvotes: 6

Mim O'Flynn
Mim O'Flynn

Reputation: 1

In case it's any help, I had this issue also but found a different reason:

I tried uploading the file several times and it just showed a 'spinning red circle' icon so I thought it was my wifi connection initially. I finally realised that the file was empty (0 bytes).

I'd run an earlier Colab session but as there were no records for that night's run, an empty .txt file had (correctly) been produced. Seems it is not possible to upload an empty file to Colab! My solution was to edit the file, adding a '.' (1 byte) to get it to upload.

Upvotes: 0

Vaibhav Pandey
Vaibhav Pandey

Reputation: 61

I was on Firefox and manual uploads, but I was facing issues. It used to work mostly. I then tried using Google Chrome and it worked.

Was getting a red circle with file upload status

Upvotes: 4

Naveen Verma
Naveen Verma

Reputation: 1

Open Google Colab Mount your google drive and wait for it to happen. Now upload your file at a suitable location on drive.

Go to colab. Browse to your file location in google colab. Click on 3 dots at the right of the browsed file. click on copy path. use this path to open the file in code block of google colab.

Upvotes: 0

Imt3aj
Imt3aj

Reputation: 11

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.

Upvotes: 1

Memphis Meng
Memphis Meng

Reputation: 1681

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

Upvotes: 0

Related Questions