Ajax + Django + jQuery + HTML5

50 views
Skip to first unread message

setivo...@gmail.com

unread,
Feb 28, 2016, 4:46:04 PM2/28/16
to Django users

I need get path to local file in <input type='file'> for ImageField.
Next, transfer path to my view thought Ajax request, update in database and almost  all.

I need will make it manually, for my goals.

May be, anyone known how it make?

I am tried already django-ajaximage, Ajaxfileupload and many other, but it not working correct for me.

Harlin Seritt

unread,
Feb 28, 2016, 5:18:32 PM2/28/16
to django...@googlegroups.com
Usually image_file.url (assuming image_file is the name of your ImageField) should give you the full path to the local file. Not sure what you're using for your Ajax function/call though and how you have your web app set up on the REST part.

--
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...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b6f047cb-abd0-41e4-bbcb-600053601144%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tom Evans

unread,
Feb 29, 2016, 1:45:22 PM2/29/16
to django...@googlegroups.com
You cannot retrieve the path of the submitted file server side, it is
simply not possible - browsers will not share that information with
you, neither via HTTP requests, nor by poking at the DOM with
javascript.

If it is absolutely necessary, you must provide a second text input
and have the user manually put the information in there. Bear in mind
that there would be no way of verifying that what the user put in that
box is at all correct.

Can you explain what you are trying to do rather than what is going
wrong, because I think that would be illuminating.

Cheers

Tom
Reply all
Reply to author
Forward
0 new messages