i have a problem whiile trying to upload files to a WebServer.
this is the code i'm using:
File file = new File(fileUri.getPath());
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(URL_connect);
Log.e("subiendo archivo",fileUri.getPath());
InputStreamEntity reqEntity = new InputStreamEntity(
new FileInputStream(file), -1);
reqEntity.setContentType("binary/octet-stream");
reqEntity.setChunked(true); // Send in multiple parts if needed
httppost.setEntity(reqEntity);
HttpResponse response = httpclient.execute(httppost);
//Do something with response...
} catch (Exception e) {
e.printStackTrace();
Toast toast1 = Toast.makeText(getApplicationContext(),"Error "+e, Toast.LENGTH_SHORT);
toast1.show();
Vibrator vibrator =(Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(200);
}
But there's no way, the file is not being uploaded to the server, i'm trying this on server side:
$file = $_FILES["file"];
$nombre_archivo = $_FILES['file']['name'];
$tipo_archivo = $_FILES['file']['type'];
$tamano_archivo = $_FILES['file']['size'];
$temporal = $_FILES['file']['tmp_name'];
move_uploaded_file($temporal, "../img/media/".$nombre_archivo);
And in the LogCat there's nothing concerning the upload, it just prints the Log.e("uploading file","name and path of the file").
What's the problem?