You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
jfu - views.py
why after instance.save(), instance.name becomes sth like "C:/foo/bar.jpg" what if I need only "bar.jpg"? I tried to change it but after instance.save() it goes back again.
I need it to be a "bar.jpg" because I want to handle it with easythumb
@require_POST
def upload( request,topic_id = ''):
if topic_id == '':
pass
else:
t = topic.objects.get(id = topic_id)
if t.picture != None:
return None
# The assumption here is that jQuery File Upload
# has been configured to send files one at a time.
# If multiple files can be uploaded simulatenously,
# 'file' may be a list of files.
file = upload_receive( request )
instance = Photo( file = file )
instance.slug = os.path.basename(instance.file.name)
instance.file.name = os.path.basename(instance.file.name)
instance.save()
try:
t.picture = instance
t.save()
except:
pass
basename = os.path.basename( instance.file.path )
file_dict = {
'name' : basename,
'size' : file.size,
'url': settings.MEDIA_URL + basename,
'thumbnailUrl': settings.MEDIA_URL + basename,
# 'deleteUrl': reverse('jfu_delete', kwargs = { 'pk': instance.pk }),
# 'deleteType': 'POST',
}
return UploadResponse( request, file_dict )
The text was updated successfully, but these errors were encountered:
jfu - views.py
why after instance.save(), instance.name becomes sth like "C:/foo/bar.jpg" what if I need only "bar.jpg"? I tried to change it but after instance.save() it goes back again.
I need it to be a "bar.jpg" because I want to handle it with easythumb
The text was updated successfully, but these errors were encountered: