estoy comenzando en android y la verdad aun no puedo reaccionar muy bien ante los errores, estoy trabajando en una aplicacion para capturar imagenes desde la camara y subirlas al servidor todo funciona perfecto pero a la hora de precionar el boton subir solo almacena el nombre de la imagen en mi tabla y no sube la imagen a la carpeta
los archivos php son
upload.php
<?PHP
$ruta = "imagenes/" .basename($_FILES['fotoUp']['name']);
if(move_uploaded_file($_FILES['fotoUp']['tmp_name'], $ruta))
chmod ("uploads/".basename( $_FILES['fotoUp']['name']), 0644);
?>
insertImagen.php
<?PHP
$hostname_localhost ="localhost";
$database_localhost ="basededatos";
$username_localhost ="root";
$password_localhost ="";
$localhost = mysql_connect($hostname_localhost,$username_localhost,$password_localhost)
or
trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database_localhost, $localhost);
$imagen=$_POST['imagen'];
$query_search = "insert into imagenes(imagen) values ('".$imagen."')";
$query_exec = mysql_query($query_search) or die(mysql_error());
mysql_close($localhost);
?>
el metodo android
private void uploadFoto(String imag) {
HttpClient httpclient = new DefaultHttpClient();
httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
HttpPost httppost = new HttpPost("/upload.php");
MultipartEntity mpEntity = new MultipartEntity();
ContentBody foto = new FileBody(file, "image/jpeg");
mpEntity.addPart("fotoUp", foto);
httppost.setEntity(mpEntity);
try {
httpclient.execute(httppost);
httpclient.getConnectionManager().shutdown();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
private boolean onInsert(){
HttpClient httpclient;
List<NameValuePair> nameValuePairs;
HttpPost httppost;
httpclient=new DefaultHttpClient();
httppost= new HttpPost("/insertImagen.php");
nameValuePairs = new ArrayList<NameValuePair>(1);
boolean imagen = nameValuePairs.add(new BasicNameValuePair("imagen", nombreImagen.getText().toString().trim() + ".jpg"));
try {
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
httpclient.execute(httppost);
return true;
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return false;
}