Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

Posts: 1
Registered: ‎12-27-2011
My Device: 8300
My Carrier: NONE

File Upload Black berry

**i am using the <h1>below code for uploading file (php + java code). but it’s not uploading.</h1>**


        1. file is present in card(simulator) i check it via file explorer demo .

        2. i tried to write text file when it hit the page but it’s not writing.

        3. I have taken the code of file upload from another site. But can’t able to use .


        So please share any code or remove error from the bellow code.

 Thanks in advance





    /******************Black Berry  Java Code ******************/

    package mypackage;


    import java.io.IOException;

    import java.io.InputStream;

    import java.io.OutputStream;

    import javax.microedition.io.Connector;

    import javax.microedition.io.HttpConnection;

    import javax.microedition.io.file.FileConnection;

    import net.rim.device.api.ui.UiApplication;

    import net.rim.device.api.ui.container.MainScreen;


    public final class MyScreen extends MainScreen


    public MyScreen() throws IOException


    synchronized (UiApplication.getEventLock()) {




    public void uplaod_file() throws IOException{

    HttpConnection httpConn = (HttpConnection) Connector.open("http://localhost/upload/upload_file.php");//file

    FileConnection fileConn = (FileConnection) Connector.open("file:///SDCard/n.txt");

    InputStream in = fileConn.openInputStream();

    OutputStream out = httpConn.openOutputStream();

    byte[] buffer = new byte[1000];

    int bytesRead = 0;


    while((bytesRead) > 0)


    out.write(buffer, 0, bytesRead);





        /****************** Php code****************** /


          if ($_FILES["file"]["error"] > 0)


        echo "Return Code: " . $_FILES["file"]["error"] . "<br />";




        /*-File writeing check*/

        $myFile = "testFile.txt";

        $fh = fopen($myFile, 'w') or die("can't open file");

        fwrite($fh, "that");



         echo "Upload: " . $_FILES["file"]["name"] . "<br />";

         echo "Type: " . $_FILES["file"]["type"] . "<br />";

         echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";

         echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";


         if (file_exists("upload/" . $_FILES["file"]["name"]))


         echo $_FILES["file"]["name"] . " already exists. ";





         "upload/" . $_FILES["file"]["name"]);

         echo "Stored in: " . "upload/" . $_FILES["file"]["name"];





New Developer
Posts: 77
Registered: ‎10-23-2008
My Device: 9000

Re: File Upload Black berry



maybe you testing the Extension "FileUpload" from github?