doulin4844 2015-12-22 12:58
浏览 125

将文件从android上传到laravel php服务器

This is my php laravel code to change/upload image. I want to upload file from android device. I have server side code only. how to send file from android???

//change org logo
    public function change_orgLogo() {

        $input = Input::all();

        $file = Input::file('file');

        if ($file) {
            $destinationPath = 'images/org_logo/'.Input::get('org_id').'/';
            $filename = $file->getClientOriginalName();

            $upload_success = Input::file('file')->move($destinationPath, $filename);
            $picUrl = 'images/org_logo/'.Input::get('org_id').'/'.$filename;
        } else {
            $picUrl = Organizationinfo::where("id", Input::get('org_id'))->pluck("logo");
            $upload_success = true;
        }

        if (Input::get('company_name') != null && Input::get('company_name') != "") {
            $cmpName = Input::get('company_name');
        } else {
            $cmpName = Organizationinfo::where("id", Input::get('org_id'))->pluck("name");
        }

        if ($upload_success) {
            $res = Organizationinfo::where('id', Input::get('org_id'))->update(['logo' => $picUrl, 'name' => $cmpName]);

            if ($res)
                return Redirect::back()->with('Changes saved successfully');
            else
                return Redirect::back()->with('Error while changing image');

        } else {
            return Redirect::back()->with('Error while changing image');
        }
    }

This is my client side code to post request to server.

//edit org info
    private class EditOrgInfo extends RemoteDataExporter {
        String choice;

        public EditOrgInfo(Context appContext) {
            super(editOrgURL, UserManagementActivity.this);
            this.choice = choice;
        }

        @Override
        HashMap<String, String> buildMapFromValue() {
            HashMap<String, String> maps = new HashMap<String, String>();

            maps.put(TAG_NAME, edt_org_name.getText().toString());
            return maps;
        }

        @Override
        void processPostExecute() {

        }
    }
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测