<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

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

    主站蜘蛛池模板: 锡林郭勒盟| 保康县| 康定县| 治多县| 嘉善县| 闽侯县| 玛多县| 平南县| 西吉县| 西峡县| 道真| 澜沧| 巴青县| 福海县| 淳安县| 罗定市| 万州区| 正安县| 英山县| 肇州县| 张掖市| 福州市| 稻城县| 康平县| 天津市| 苍南县| 德钦县| 安福县| 呈贡县| 江华| 城固县| 剑河县| 娱乐| 夹江县| 新巴尔虎左旗| 芒康县| 封开县| 易门县| 盱眙县| 荣昌县| 水城县|