Android Question upload file With php

Discussion in 'Android Questions' started by Spinter, Feb 6, 2014.

  1. Spinter

    Spinter Active Member Licensed User

    I'm sorry my english with google translate
    I need help. I would like to upload a file or an image with the php page on the webserver ?

    I found and tried many posts but nothing that would lead me to solve. Can you help me?
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. Spinter

    Spinter Active Member Licensed User

    thanks erel I've seen many posts for your feedback!
    I tried but I did not get a result.
    There are few examples with php I'm not able!
    There is none who can help me?
  4. lemonisdead

    lemonisdead Well-Known Member Licensed User

    Hello Spinter,
    Please, is it a problem about PHP or with B4A ? What don't you know how to do ?

    Ciao Spinter,
    Per favore, è un problema di PHP o con B4A? Quello che non sai come fare?
  5. Spinter

    Spinter Active Member Licensed User

    Scusa me sei italiano?
    My post italian forum

    Per sincerità avrei bisogno di un esempio completo!sia B4A che php!
    Ho usato questo tipo di inserimento dati ma non vorrei usare base64.
    Vorrei riuscire ad usare il multirepart request per inviare più file.

    Traslated by Google!
    For sincerity I would need a complete example! B4A is that php!
    I have used this type of data entry but I would not use base64.
    I would like to be able to use the multirepart request to send multiple files.


    Dim linkdb As String
    Dim su As StringUtils
    Dim out1 As OutputStream
    100'size not really important
    File.Copy2( File.OpenInput(File.DirRootExternal,"1.jpg"), out1)     
    job_camera_1.PostString(linkdb, su.EncodeBase64(out1.ToBytesArray))

        $base = file_get_contents(
    'Content-Type: bitmap; charset=utf-8');
        $file = fopen('images/test_image.jpg', 'wb');
        fwrite($file, $binary);
        print json_encode(
    'Image Upload Complete');
    Mashiane likes this.
  6. DonManfred

    DonManfred Expert Licensed User

    Have a look at this example it uses erels multipartpost.bas. It uploads two files to a phpscript. On phpside the uploads are written to uploads-folder

    Edit 29. August 2015:
    I´ve added a new version of the example. This example uses the new okHTTP-Library.
    Please note that i need to change the module multipartpost.bas to be compatible with the new okHTTP

    Attached Files:

    Last edited: Aug 29, 2015
  7. Spinter

    Spinter Active Member Licensed User

    Thank you so much!
  8. Spinter

    Spinter Active Member Licensed User

    Return me this error

    error: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">

    <title>501 Method Not Implemented</title>
    <h1>Method Not Implemented</h1>
    <p>GET to /B4A1.php not supported.<br />
    <p>Additionally, a 404 Not Found
    error was encountered while trying to use an ErrorDocument to handle the request.</p>
    <address>Apache Server at Port 80</address>
  9. DonManfred

    DonManfred Expert Licensed User

    something wrong with your webserverconfig? Can you call the php directly from browser? just call without parameters

    The url in example works. I have tested it. something must be wrong
  10. Spinter

    Spinter Active Member Licensed User

    I use a webhost on
    Maybe I have to configure anything?
    I do not know much about php you can help me.
  11. DonManfred

    DonManfred Expert Licensed User

    i dont know. i dont know this hoster and their possibilities at a webhosting...

    Did you have PHP available on it? If yes, did you get any output from the multipartpost.php php-script when calling directly from a browser on your pc?

    maybe you can post your app here. Export to zip
    Also post the php-script you are using.... i can try it on my webspace then
  12. lemonisdead

    lemonisdead Well-Known Member Licensed User

  13. DonManfred

    DonManfred Expert Licensed User

    @Spinter Please change the MultiPartPost.php! If you want to use it, it is incomplete for you and may output errors

    Open PHP in Texteditor. On line 3 you´´ll find

    PLEASE REMOVE THIS LINE! The script kernel.php is not part of this example and is not needed here.

    Remark: I have updated the file in my post with the example.

    That could be a solution for your errors. Maybe "include" is not allowed ("501 Method Not Implemented") AND the file kernel.php does not exists cause it was not part of the zip. Better to remove this line :)

    Sorry, i did not recognized this line cause it is a standard-part of all php-projects i have made. So i overread them ;-)
    (In kernel the database is initialized for example)

    I forgot to remove this line before uploading it here. Sorry

    It may fix your problem but if not you should check your php-config at your webhoster as posted from the dead lemon :D
  14. Spinter

    Spinter Active Member Licensed User

    I am trying your example without modification to test if it works!

    I had read but my problem is that I do not know what I have to add!


    I had already removed it I knew that I needed!

    thank you very much but I can not figure out the problem of the web server!
  15. Spinter

    Spinter Active Member Licensed User

    As an experiment I tried a code in vb2010 and I tried it and it works perfectly!

    So I think that the server-side function right?
  16. DonManfred

    DonManfred Expert Licensed User

    For THIS php-Code

    You have to change things in APP-Code (you said you´re using it unchanged)

  17. Spinter

    Spinter Active Member Licensed User

    I tried it with your latest code I always generates the same error!

    I tried this code with Eclipse, and it works! I can not understand where is the error in B4A!

  18. Douglas Farias

    Douglas Farias Expert Licensed User


    how can i get only a note1 value?

    if (isset($_REQUEST['note1'])){
    foreach($_REQUEST as $name => $value){
    } else {

    i m trying make this this get the value abc ok and make a dir in naoenviadas/abc

    but make anothers folders
    cde and upload

    how can i get only the note1 value to make a dir?

    i try this too but dont work =(
    $codigo = $_GET['note1'];
    Last edited: May 19, 2014
  19. DonManfred

    DonManfred Expert Licensed User

    } else {
    Devan and Douglas Farias like this.
  20. Spinter

    Spinter Active Member Licensed User

  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