<button id="g80sy"></button>
  • <abbr id="g80sy"></abbr>
  • <button id="g80sy"></button>
    <rt id="g80sy"><delect id="g80sy"></delect></rt>
  • Vue 點擊按鈕 觸發 input file 選擇文件

    程序猿 2022-04-27 22:25:04 2119瀏覽 加載中
    vs.$refs.upload1.dispatchEvent(new MouseEvent('click'));
    fileChange(e) {
        console.log(e.target.files[0])
        let formDate = new FormData();
        formDate.append('file',e.target.files[0])
        formDate.append('order_id',vs.info.id)
        axios.post("{:url('Order/uploadHeTong')}",formDate).then((res)=>{
            console.log(res)
        })
    },
    <input ref="upload" type="file" id="upload" style="display: none" @input="fileChange">
    <el-link @click="upload(info.id)">上傳</el-link>
    upload() {
        vs.$refs.upload.dispatchEvent(new MouseEvent('click'));
    },
    $file = $_FILES["file"];
    return json(input());
    if (!is_dir('uploads')) mkdir('uploads');
    $ext = strtolower(strrchr($file["name"],"."));
    
    if (!is_dir('uploads/he')) {
        mkdir('uploads/he');
    }
    $path = "uploads/he/" . date('Ym');
    if (!is_dir($path)) {
        mkdir($path);
    }
    $name = md5(time() . Str::random(6)) . $ext;
    $name = $path . "/" . $name;
    if (!move_uploaded_file($file["tmp_name"],$name)) {
        return $this->error("上傳失敗");
    }
    return json(['path'=>$name]);


    標簽:
    最后修改:2025-05-30 00:27:46

    非特殊說明,本博所有文章均為博主原創。

    主站蜘蛛池模板: 阿鲁科尔沁旗| 墨玉县| 永城市| 许昌市| 宣城市| 乾安县| 宣化县| 富锦市| 宁河县| 凤城市| 交城县| 和政县| 墨竹工卡县| 昌宁县| 兰溪市| 博客| 新乐市| 祁东县| 凤山县| 望谟县| 石河子市| 邯郸县| 岐山县| 恩施市| 柏乡县| 十堰市| 电白县| 清原| 明溪县| 博白县| 南丹县| 安龙县| 临漳县| 肃宁县| 蒙阴县| 正安县| 黄龙县| 阳曲县| 盐源县| 方正县| 绥江县|