I am trying to upload an image to the SQLite database in a blob format. I run in to the problem when I am trying to get an absolute path to the image. The error I am getting is
FileNotFoundError: [Errno 2] No such file or directory: '/home/ubuntu/environment/finance/IMG_7528.JPG' I understand that it is looking for the image in my directory but I want it to be getting the image from the path on my computer, for example
Below is my code to get the path but the path is still showing the above error
def convertToBinaryData(filename): #Convert digital data to binary format my_path = os.path.abspath(os.path.dirname(__file__)) path = os.path.join(my_path, filename) with open(path, 'rb') as file: blobData = file.read() return blobData
Is there a way to get the absolute path of an image that I am trying to upload from my desktop into Cloud9 IDE?