I use this code for upload image:
http://vikaskanani.wordpress.com/2011/01/11/android-upload-image-or-file-using-http-post-multi-part/
I replaced
bm = BitmapFactory.decodeFile("/data/data/fshizzle.com/files/image.jpg");
and
HttpPost postRequest = new HttpPost("http://10.0.2.2/upload.php");
it's all!
I can not receved info in php file
I use this code php work if use html code
<form method="POST" action="upload.php" enctype="multipart/form-data">
<!-- On limite le fichier à 100Ko -->
<input type="hidden" name="MAX_FILE_SIZE" value="100000">
Fichier : <input type="file" name="avatar">
<input type="submit" name="envoyer" value="Envoyer le fichier">
</form>
CODE PHP:
$dossier = './upload/';
$fichier = basename($_FILES['sfsdfsdf']['name']);
if(move_uploaded_file($_FILES['sfsdfsdf']['tmp_name'], $dossier . $fichier))
//Si la fonction renvoie TRUE, c'est que ?a a fonctionné...
{
echo 'Upload effectué avec succès !';
}
else //Sinon (la fonction renvoie FALSE).
{
echo '<br>Echec de l'upload !';
}
a simple if(isset($_FILES['sfsdfsdf']))
don't work what is a good code?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…