Android Question http how to upload a picture to a website location

Discussion in 'Android Questions' started by raphipps2002, Sep 14, 2015.

  1. raphipps2002

    raphipps2002 Active Member Licensed User

    I have just started to learn HTTP; and have started with a simple download and upload of a picture (jpeg). The credentials and path to website work Ok as the image is downloaded. But I get an error when trying to Upload 2.jpg. Can someone explain in simple terms my error.

    I placed the 2.jpg in the files folder of the package name

    Code:
    Sub Activity_Create(FirstTime As Boolean)
       
       
    Dim job1, job2, job3 As HttpJob
     
       job1.Initialize(
    "Job1", Me)
          
    'Send a GET request
       job3.Initialize("Job3", Me)
      
       job3.Username = 
    "uxxxxxxx7"
       job1.Password = 
    "7xxxxxt"
      
       job3.Download(
    "http://www.mydomain.com/HTTPPictures/1.jpg")
       
    'Send a POST request
       job2.Initialize("Job2", Me)
          
    Dim Apath As String = File.DirDefaultExternal

        job2.PostFile(
    "http://www.mydomain.com/HTTPPictures/", Apath ,"2.jpg")
       
       
     
    End Sub

    Sub JobDone (Job As HttpJob)
       
    Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
       
    If Job.Success = True Then
          
    Select Job.JobName
             
    Case "Job1""Job2"
                
    'print the result to the logs
                Log(Job.GetString)
             
    Case "Job3"
                
    'show the downloaded image
                Activity.SetBackgroundImage(Job.GetBitmap)
          
    End Select
       
    Else
          
    Log("Error: " & Job.ErrorMessage)
          
    ToastMessageShow("Error: " & Job.ErrorMessage, True)
       
    End If
       
    End Sub
     
  2. DonManfred

    DonManfred Expert Licensed User

    When you get any error it is not the right way to hide the error to us

    But that´s not the file you want to upload...

    You are trying to upload a file in DirDefaultExternal... Did you copy your file from the assets to this path first?

     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice