Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/190.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如果extis通过post使用java将整个文件夹上载到服务器_Java_Android - Fatal编程技术网

如果extis通过post使用java将整个文件夹上载到服务器

如果extis通过post使用java将整个文件夹上载到服务器,java,android,Java,Android,我是一个java新手,我需要完成这个应用程序并通过Post将整个文件夹发送到我的服务器 现在代码可以工作了,但我需要检查是否存在特定的文件夹名称和路径,然后使用线程上载功能发送所有文件 参考代码: public class UploadToServer extends Activity { TextView messageText; Button uploadButton; int serverResponseCode = 0; ProgressDialog d

我是一个java新手,我需要完成这个应用程序并通过Post将整个文件夹发送到我的服务器

现在代码可以工作了,但我需要检查是否存在特定的文件夹名称和路径,然后使用线程上载功能发送所有文件

参考代码:

public class UploadToServer extends Activity {

    TextView messageText;
    Button uploadButton;
    int serverResponseCode = 0;
    ProgressDialog dialog = null;

    String upLoadServerUri = null;

    /**********  File Path *************/
    final String uploadFilePath = "/mnt/sdcard/folder/";
    final String uploadFileName = "sample.jpg";

    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_upload_to_server);

        uploadButton = (Button)findViewById(R.id.uploadButton);
        messageText  = (TextView)findViewById(R.id.messageText);

        messageText.setText("Uploading file path :- " + uploadFilePath + uploadFileName);

        /************* Php script path ****************/
        upLoadServerUri = "http://www.tutomax.com/uploads/Receiver.php";

        uploadButton.setOnClickListener(new OnClickListener() {            
            @Override
            public void onClick(View v) {

                dialog = ProgressDialog.show(UploadToServer.this, "", "Uploading file...", true);

                new Thread(new Runnable() {
                        public void run() {
                             runOnUiThread(new Runnable() {
                                    public void run() {
                                        messageText.setText("uploading started.....");
                                    }
                                });                      

                             uploadFile(uploadFilePath + "" + uploadFileName);

                        }
                      }).start();        
                }
            });
    }

    public int uploadFile(String sourceFileUri) {

。。。。REST代码上传功能

如何浏览指定文件夹下的所有文件,然后逐个上传匹配的文件。

您发布的代码的哪一部分与您的问题相关?请精简代码;没人想通读所有这些。嗨,Gunr2171,对不起,你说得对,这是很长的一段。谢谢你的建议。赛亚