Le téléchargement de plusieurs image sur serveur php à partir d'android

Aider de ce côté serveur de code php, je n'ai pas de connaissances en php et j'ai télécharger les trois images à partir d'android cette page php.

J'ai essayé de nombreuses méthodes et cherché, mais pas de tutoriel ou quoi que ce soit ne m'a pas aidé mon android code fonctionne correctement. DNS configuré mais les images ne sont pas affichées sur le côté serveur. Merci de m'aider avec le code java.

PHP:

<?php
if ($_FILES["file1"]["error"] > 0)
{
header("HTTP/1.1 400 Bad Request");
echo "Error: " . $_FILES["file1"]["error"] . "<br />";
}
else if ($_FILES["file2"]["error"] > 0)
{
header("HTTP/1.1 400 Bad Request");
echo "Error: " . $_FILES["file1"]["error"] . "<br />";
}
else if ($_FILES["file3"]["error"] > 0)
{
header("HTTP/1.1 400 Bad Request");
echo "Error: " . $_FILES["file1"]["error"] . "<br />";
}
else
{
if ($_FILES["file1"]["error"] > 0)
{
echo "Error: " . $_FILES["file1"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file1"]["name"] . "<br />";
echo "Type: " . $_FILES["file1"]["type"] . "<br />";
echo "Size: " . ($_FILES["file1"]["size"] / 1024) . " Kb<br />";
echo "Stored in: " . $_FILES["file1"]["tmp_name"]. "<br />";
}
//$target_path = "uploads/";
$target_path = "elp/pendingimages/";
$target_path = $target_path . basename( $_FILES['file1']['name']); 
if(move_uploaded_file($_FILES['file1']['tmp_name'], $target_path)) {
echo "The file ".  basename( $_FILES['file1']['name']). 
" has been uploaded"; 
} 
else{
echo "There was an error uploading the file, please try again!";
}
if ($_FILES["file2"]["error"] > 0)
{
echo "Error: " . $_FILES["file2"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file2"]["name"] . "<br />";
echo "Type: " . $_FILES["file2"]["type"] . "<br />";
echo "Size: " . ($_FILES["file2"]["size"] / 1024) . " Kb<br />";
echo "Stored in: " . $_FILES["file2"]["tmp_name"]. "<br />";
}
//$target_path = "uploads/";
$target_path = "elp/pendingimages/";
$target_path = $target_path . basename( $_FILES['file2']['name']); 
if(move_uploaded_file($_FILES['file2']['tmp_name'], $target_path)) {
echo "The file ".  basename( $_FILES['file2']['name']). 
" has been uploaded";
} 
else{
echo "There was an error uploading the file, please try again!";
}
if ($_FILES["file3"]["error"] > 0)
{
echo "Error: " . $_FILES["file3"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file3"]["name"] . "<br />";
echo "Type: " . $_FILES["file3"]["type"] . "<br />";
echo "Size: " . ($_FILES["file3"]["size"] / 1024) . " Kb<br />";
echo "Stored in: " . $_FILES["file3"]["tmp_name"]. "<br />";
}
//$target_path = "uploads/";
$target_path = "elp/pendingimages/";
$target_path = $target_path . basename( $_FILES['file3']['name']);  
if(move_uploaded_file($_FILES['file3']['tmp_name'], $target_path)) {
echo "The file ".  basename( $_FILES['file3']['name']). 
" has been uploaded";
} 
else{
echo "There was an error uploading the file, please try again!";
}
}
?>

Java:

public class TryprojectActivity extends Activity {
InputStream is;
int pic_count = 0;
Bitmap bitmap=null;
FileInputStream in1,in2,in3;
BufferedInputStream buf;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
try {
in1 = new FileInputStream("/sdcard/1.jpg");
} 
catch (FileNotFoundException e2) {
//TODO Auto-generated catch block
e2.printStackTrace();
}
try {
in2 = new FileInputStream("/sdcard/2.jpg");
} catch (FileNotFoundException e1) {
//TODO Auto-generated catch block
e1.printStackTrace();
} 
try {
in3 = new FileInputStream("/sdcard/3.jpg");
} 
catch (FileNotFoundException e1) {
//TODO Auto-generated catch block
e1.printStackTrace();
} 
Bitmap bitmapOrg1 = BitmapFactory.decodeStream(in1);
ByteArrayOutputStream bao1 = new ByteArrayOutputStream();
bitmapOrg1.compress(Bitmap.CompressFormat.JPEG, 90, bao1);
byte [] imagearray1 = bao1.toByteArray();
String ba1=Base64.encode(imagearray1);
Bitmap bitmapOrg2 = BitmapFactory.decodeStream(in2);
ByteArrayOutputStream bao2 = new ByteArrayOutputStream();
bitmapOrg2.compress(Bitmap.CompressFormat.JPEG, 90, bao2);
byte [] imagearray2 = bao2.toByteArray();
String ba2=Base64.encode(imagearray2);
Bitmap bitmapOrg3 = BitmapFactory.decodeStream(in3);
ByteArrayOutputStream bao3 = new ByteArrayOutputStream();
bitmapOrg3.compress(Bitmap.CompressFormat.JPEG, 90, bao3);
byte [] imagearray3 = bao3.toByteArray();
String ba3=Base64.encode(imagearray3);
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(3);
nameValuePairs.add(new BasicNameValuePair("image1",ba1));
nameValuePairs.add(new BasicNameValuePair("image2",ba2));
nameValuePairs.add(new BasicNameValuePair("image3",ba3));
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://helpdesk.cispl.com/upload_file.php");
UrlEncodedFormEntity obj = new UrlEncodedFormEntity(nameValuePairs);
obj.setChunked(true);
httppost.setEntity(obj);
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
//is = entity.getContent();
httpclient.getConnectionManager().shutdown(); 
}
catch(Exception e){
//CommonFunctions.writeLOG(ctx.getClass().toString(), e.toString());
//CommonFunctions.showToast(ctx, "Unable to post captured image file: " +
//e.toString());
}
}
Ces images doit être téléchargés via HTTP, comment vous faire de votre envoi? (Puisque vous avez mentionné Java)
Je veux dire que le java code d'Activité nécessaires à l'application android. Et j'en ai marre de charger à l'aide de http et mulitpart aussi, mais pas de l'utiliser. C'est peut-être en passe de provoquer ma je en essayant de code sans savoir à propos de php.
Nous montrer le code.
le code php est correct. Donc, ne blâmez pas votre php connaissances. Regarde comme il y a des erreurs dans votre multipart demande.
J'ai essayé avec plusieurs parties trop mais actuellement, je me débrouille avec ce code et il n'y a pas d'erreur dans le code ou autre :S

OriginalL'auteur user1160020 | 2012-01-20