如何使用javascript从系统上传文件

时间:2017-01-13 17:53:33

标签: javascript

我正在编写自动化脚本来上传Mp3文件。我可以自动执行直到单击“浏览”按钮。然后我无法从特定文件夹路径中选择文件。(要执行此步骤,我需要在JavaScript中执行此操作。任何人都可以帮助我吗?

文件上传前的HTML代码

<div class="flex-100" flex="100">
    <div class="lf-ng-md-file-input ng-pristine ng-untouched ng-isolate-scope layout-column ng-valid-mimetype ng-valid-filesize ng-invalid ng-invalid-required" ng-model="lfobj120f0754" layout="column" lf-api="lfAudioApi" lf-mimetype="audio/*" lf-filesize="10MB" lf-required="" lf-files="audioFile" name="files" aria-required="true" aria-invalid="true" style="">
        <div class="lf-ng-md-file-input-preview-container layout-column ng-hide" ng-show="isDrag || (isPreview && !isFilesNull)" ng-class="{'disabled':isDisabled}" layout="column" aria-hidden="true">
            <div class="close lf-ng-md-file-input-x ng-hide" ng-hide="isFilesNull" ng-click="removeAllFiles($event)" role="button" tabindex="0" aria-hidden="true" style="">×</div>
            <div class="lf-ng-md-file-input-drag">
                <div class="lf-ng-md-file-input-drag-text-container layout-align-center-center layout-row ng-hide" ng-show="isFilesNull && isDrag" layout-align="center center" layout="row" aria-hidden="true">
                    <div class="lf-ng-md-file-input-drag-text ng-binding">Drag & drop files here...</div>
                </div>
                <div class="lf-ng-md-file-input-thumbnails"></div>
                <div class="clearfix" style="clear:both"></div>
            </div>
        </div>
        <div class="lf-ng-md-file-input-container layout-row" layout="row">
            <div class="lf-ng-md-file-input-caption layout-align-start-center layout-row flex" ng-class="{'disabled':isDisabled}" flex="" layout-align="start center" layout="row">
                <md-icon class="lf-icon material-icons lf-caption" ng-class="strCaptionIconCls" aria-hidden="true"></md-icon>
                <div class="lf-ng-md-file-input-caption-text-default ng-binding flex" ng-show="isFilesNull" flex="" aria-hidden="false" style="">Select file</div>
                <div class="lf-ng-md-file-input-caption-text ng-binding flex ng-hide" ng-hide="isFilesNull" flex="" aria-hidden="true" style=""></div>
                <md-progress-linear class="ng-hide" ng-show="intLoading && isProgress" value="100" md-mode="determinate" aria-valuemin="0" aria-valuemax="100" role="progressbar" aria-valuenow="100" aria-hidden="true">
                    <div class="_md-container _md-mode-determinate">
                        <div class="_md-dashed"></div>
                        <div class="_md-bar _md-bar1"></div>
                        <div class="_md-bar _md-bar2" style="transform: translateX(0%) scale(1, 1);"></div>
                    </div>
                </md-progress-linear>
            </div>
            <button class="md-raised lf-ng-md-file-input-button lf-ng-md-file-input-button-remove md-button md-ink-ripple ng-hide" ng-transclude="" type="button" ng-hide="isFilesNull || intLoading" ng-click="removeAllFiles()" ng-disabled="isDisabled" aria-hidden="true" aria-disabled="false" aria-label="Remove" style="">
                <md-icon class="lf-icon ng-scope material-icons lf-remove" ng-class="strRemoveIconCls" aria-hidden="true"></md-icon>
                <span class="ng-binding ng-scope"> Remove</span>
                <div class="md-ripple-container" style=""></div>
            </button>
            <button class="md-raised md-primary lf-ng-md-file-input-button lf-ng-md-file-input-button-brower md-button md-ink-ripple" ng-transclude="" type="button" ng-click="openDialog($event, this)" ng-disabled="isDisabled" aria-disabled="false">
                <md-icon class="lf-icon ng-scope material-icons lf-browse" ng-class="strBrowseIconCls" aria-hidden="true"></md-icon>
                <span class="ng-binding ng-scope"> Browse</span>
                <input id="input_11" class="lf-ng-md-file-input-tag ng-scope md-input" type="file" ng-disabled="isDisabled" accept="" aria-label="" aria-disabled="false">
                <div class="md-errors-spacer"></div>
                <div class="md-ripple-container" style=""></div>
            </button>
        </div>
    </div>
</div>

0 个答案:

没有答案