On Tue, Feb 3, 2015 at 7:22 AM, bradford li <bradfor...@gmail.com> wrote: > There is bounty on this stackoverflow question is anyone is interested >
It looks like it has already been answered multiple times - you cannot upload a file in to a subdirectory of MEDIA_ROOT and have its name attribute be the base file name. The name attribute of a FileField is the path to the file relative to MEDIA_ROOT*. If you want to store files in subfolders of MEDIA_ROOT, then obviously, the name attribute will not consist of just the file name of the uploaded file. If you want to know or use the name of the file, use os.path.basename() on the name attribute. Cheers Tom * This isn't actually true, but is close enough to the truth as makes no difference. It is in fact relative to whatever "storage engine" that FileField uses; the default storage engine behaves as I have described. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFHbX1KuXPScTGkZtPynf7cgNM_CNAHJ8DPrn1tooT-83PgamA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.