Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-9797

Android: HTTP Post will save a photo at Internal phone storage

    Details

      Description

      Issue

      HTTP Post a photo that will be saved at Internal phone storage

      Tested on

      Droid Razr 2.3.5

      Repro steps

      1) Run code below & pick up an image from the gallery
      2) Wait till the image gets uploaded
      3) Go through with any File Manager app to monitor Internal phone storage directory. Notice the uploaded image is present at such location having a similar file name: "tixhr***.jpeg"

      Repro sequences
      • app.js

        Titanium.Media.openPhotoGallery({
        	success:function(event){
         
        		var myImage = event.media;
         
        		var xhr = Titanium.Network.createHTTPClient();
        		xhr.open('POST','http://192.168.0.100/upload.php');
        		xhr.onerror = function(e){alert(e.error);};
        		xhr.setTimeout(200000);
        		xhr.onload = function(e){
        			Ti.UI.createAlertDialog({title:'Success', message: this.responseText
        		}).show();			
        		};
        		xhr.onsendstream = function(e){Ti.API.info(e);};
        		xhr.setRequestHeader("contentType", "multipart/form-data");
        		xhr.send({uploadedfile:myImage});
         
        	},
        	cancel:function(){
         
        	},
        	error:function(error){
        	},
        	mediaTypes:[Ti.Media.MEDIA_TYPE_VIDEO,Ti.Media.MEDIA_TYPE_PHOTO]
        });
        

      • upload.php

        <?php
         
        $target_path = "uploadedimages/";
        $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
        if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
            echo "The file ".  basename( $_FILES['uploadedfile']['name'])." has been uploaded";
        } else{
            echo "There was an error uploading the file, please try again!";
        }
         
        ?>
        

      Work around

      Walk through all files that start with the name "tixhr" to manually purge them.

        Attachments

          Activity

            People

            • Assignee:
              pwang Ping Wang
              Reporter:
              egomez Eduardo Gomez (Inactive)
            • Watchers:
              0 Start watching this issue

              Dates

              • Due:
                Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-13921
                  Sync status:
                  ERROR
                  Last sent:

                  Git Source Code