से संदर्भित किया गया है जो मैं करने का प्रयास कर रहा हूं वह एक वेब सर्वर पर एक तस्वीर भेजना है। जब मैं अपने एंड्रॉइड प्रोजेक्ट में एक विधि कॉल करता हूं तो मुझे निम्न त्रुटि मिलती है: क्लास 'org.apache.http.entity.mime.content.Filebody' नहीं मिला, विधि com.example.tc.Send.send से संदर्भित।कक्षा 'org.apache.http.entity.mime.content.Filebody' नहीं मिला, विधि
यह तब होता है eventhough मैं निम्नलिखित आयात मिल गया है:
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.impl.client.DefaultHttpClient;
इस वर्ग की तरह है, जिसमें विधि निहित है दिखता है:
public class Send {
public Send(){
}
public static String send(String path) throws Exception {
String filePath = path;
String svar;
HttpClient httpclient = new DefaultHttpClient();
try {
HttpPost httppost = new HttpPost("path to web server");
FileBody pic = new FileBody(new File(filePath));
MultipartEntity requestEntity = new MultipartEntity();
requestEntity.addPart("file", pic);
httppost.setEntity(requestEntity);
System.out.println("executing request " + httppost.getRequestLine());
HttpResponse response = httpclient.execute(httppost);
HttpEntity responseEntity = response.getEntity();
System.out.println("----------------------------------------");
System.out.println(response.getStatusLine());
ByteArrayOutputStream outstream = new ByteArrayOutputStream();
response.getEntity().writeTo(outstream);
byte [] responseBody = outstream.toByteArray();
svar = new String(responseBody);
System.out.println(svar);
} finally {
try {
httpclient.getConnectionManager().shutdown();
}
catch (Exception ignore) {
}
}
return svar;
}
}
किसी को भी देख सकते हैं कि समस्या क्या है?
आप जावा का निर्माण पथ में शामिल करने के लिए सुनिश्चित करें क्या करें? –
क्या आपको कोई जवाब मिला? –
क्या आप प्रोगार्ड का उपयोग कर रहे हैं? –