0

I have a folder "uploads" nested in "img" nested in my "static" folder. I am using the path "/static/img/uploads" to get a list of the files in the uploads folder. But I keep getting the error FileNotFoundError: [Errno 2] No such file or directory: '/static/img/uploads'. Why would this be happening? The application.py file and static folder are both in a folder called "final" so I didn't think I needed to add any other direction to get to the uploads folder. Here is the code I have right now:

path = '/static/img/uploads'
images = os.listdir(path)

I'm not sure what other information you would need to help me figure out what the problem is and I can always add more coding if it would be helpful. Here is a screenshot of the directory I am referring to:

enter image description here

1 Answer 1

1

From the python doc:

os.listdir(path='.')

Return a list containing the names of the entries in the directory given by path.

/static/img/uploads is not a absolute path in the operating system. Try using relative path eg ./static/img/uploads

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .