Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7648145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:38:29+00:00 2026-05-31T10:38:29+00:00

I am trying to upload image to django from iphone with ASIFormDataRequest. in my

  • 0

I am trying to upload image to django from iphone with ASIFormDataRequest.

in my django views.py

class UploadFileForm(forms.Form):
    name = forms.CharField(max_length=255)
    file = forms.FileField()

@csrf_exempt
def upload_image(request):
    if request.method == 'POST':
            form = UploadFileForm(request.POST, request.FILES)
            if form.is_valid(): ##this is always fail
                newimage = Image(imgfile = request.FILES['image'])
                newimage.save()

                return HttpResponse('succeeded')
            else:
                return HttpResponse('failed')

in models.py

 class Image(models.Model):
         imgfile = models.FileField(upload_to='images/')

i got this in settings.py

 MEDIA_ROOT = '/srv/www/media'

with the above code, i can’t get the form validated, but if i remove form.is_valid(), then the image is successfully uploaded to /srv/www/media/images/

and the following is the iOS code:

formRequest = [ASIFormDataRequest requestWithURL:url];
[formRequest setPostFormat:ASIMultipartFormDataPostFormat];
formRequest.delegate = self;
[formRequest setData:UIImageJPEGRepresentation(image, 1.0f) withFileName:fileName andContentType:@"image/jpeg" forKey:@"image"];
[formRequest setPostValue:userName forKey:@"name"];
[formRequest setRequestMethod:@"POST"];
[formRequest setPostFormat:ASIMultipartFormDataPostFormat];
[formRequest startAsynchronous];

please, any suggestion is welcome and appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T10:38:31+00:00Added an answer on May 31, 2026 at 10:38 am

    I don’t know anything about iOS, but looks to me that you’re providing a value for key name, but you don’t have that field in your form – you have jid instead. Since that field is required, and you’re not providing it, the form is not valid.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to upload an image from inside a JQuery modal. The form
Im struggling here for a lot, Im trying to upload an image from iphone
I am trying to implement a function in Django to upload an image from
i am trying to upload a image to server from iPhone application PHP code
I'm trying to upload an image to facebook using the iOS SDK from Facebook.
I'm trying to upload an image to my site through a form, however it's
i am trying to upload an image from a jsp page using servlet. but
I am trying to upload an image to the server. I hava a form
I am trying to upload an image to server using iphone . I haven't
In my models.py: from django.db import models from core import tasks class Image(models.Model): image

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.