<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 1978瀏覽 加載中
    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-03-23 19:21:44

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

    主站蜘蛛池模板: 汉川市| 祁门县| 西华县| 兰州市| 修水县| 新津县| 胶州市| 徐州市| 古交市| 黄梅县| 长泰县| 合阳县| 绿春县| 南开区| 天全县| 舒兰市| 新巴尔虎右旗| 朔州市| 家居| 台湾省| 青神县| 南投市| 酒泉市| 漯河市| 甘孜| 嵩明县| 甘南县| 探索| 惠来县| 循化| 屯门区| 济宁市| 东辽县| 镇平县| 滨海县| 靖宇县| 武川县| 墨竹工卡县| 房产| 上林县| 和林格尔县|