Android Question Send file to server using httputlis2 postfile

Discussion in 'Android Questions' started by Devv, Mar 24, 2015.

Similar threads

B4A Question httputlis2 post broblem
B4A Question Download image with httputlis2
B4A Code Snippet [B4X] Bytes To File
B4A Question httputlis
B4A Question java io not found !
  1. Devv

    Devv Active Member Licensed User

    Hello guys i'am trying to send a file to my server using php
    i tried the following

       $FileName = $_GET[

    if (!$FileName)
          $FileName = 

    if (strstr($FileName,"php"))

       $PostData = file_get_contents(

    File = fopen($FileName,"wb");

    File, $PostData);

    the following code is working but i'am always getting the file names as "FileName"

    WHY php is not recognizing the file name ??
    can i send the file name with the file as an extra parameter ?

    PS: i'am using httputlis2 post file to send it to the php
  2. DonManfred

    DonManfred Expert Licensed User

    Cause you dont give a filename with a postfile request.
    You need to use a multipartpost to give a file AND a (or even more) value with one postrequest.
    See my signature for a Example
    Devv likes this.
  3. Devv

    Devv Active Member Licensed User

    thanks for fast replay DonManfred
    the files i'am working with is less than 50 KB.
    sorry for this silly question but i'am a noob
    multipartpost: does mean sending the file part after part each part as one http post
    or it does mean that a single http post with more than one parameter ?

    anyway is their is a difference in the request time if using normal or multipart post ?
  4. DonManfred

    DonManfred Expert Licensed User

    See my example. I´m using two files in ONE uploadrequest. You can put more... You need to handle the files then via the $_FILES array like in an normal webpage-formular-request.
  5. DonManfred

    DonManfred Expert Licensed User

    not really... a few bytes more to send. And you need to handle the given vars in another way than you did in a postfile-request
  6. DonManfred

    DonManfred Expert Licensed User

  7. Devv

    Devv Active Member Licensed User

    Thanks bro , i'am seeing your script now
    so making a little change to my script is not possible to send a string (file name) with it ?
    i have to change the whole sender and receiver code right ?
  8. DonManfred

    DonManfred Expert Licensed User

    No using postfile


    You can store the filename in this code when sending...
    Dim fd As FileData
        fd.Dir = 
        fd.FileName = 
        fd.KeyName = 
        fd.ContentType = 
    raphaelcno and Devv like this.
  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