Reputation: 111
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
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
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
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
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
Reputation: 11
There are two ways to upload files in colab.
=> 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)
=> Click Show file browser(In Mobile Mode) or Click Folder Icon 📁(In Desktop Mode)
=> 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
Reputation: 1681
Simply put, you just need to press the button in the red circle and upload what you need.
Upvotes: 0