Upload image using jQuery, AJAX and PHP

前端 未结 2 981
臣服心动
臣服心动 2021-01-28 02:20

I\'m trying to choose an image from PC/mobile and upload it to the server on one button click but for some reason I can\'t grab the value (name) of chosen image - $_FILES[

2条回答
  •  天命终不由人
    2021-01-28 02:38

    Why not just submit the form automatically using onchange on the file input? As soon as they select a file, it will submit the image for them. Here is a jsfiddle.

    Or as is applies to your situation:

    $(document).ready(function(){
        $('#pictureCapture').change(function(){
            this.form.submit();
        });
    });
    

提交回复
热议问题