Deleteing files os.remove() from the code

Hello all,

Is there any restrictions of using os.remove() command from the web app code? I'm uploading file in the directory '/home/gt/gt/img'. Uploading is smooth, but whe I try to delete the file using next command, for some reasone it's not deleted. Filename here is string formatted as 'xxxxxx-xxxxxx-xxxxxx-xxxxxx.jpg'. x- random.

os.remove(os.path.join('/home/gt/gt/img', filename))

This command perfectly works when running BASH python...

Any suggestings? Thank you.

ohh.. nevermind.. To get a filename I was using url to get a filename and it was returning me /xxxxx-xxxx.....jpg. So eventually I was getting os.remove('/xxxxxxx-xxxxx.....jpg') instead of full path.

Fixed by using correct rsplit() to get a filname from URL.

great! full paths are also important in case your code is being run from different working directories!