小编Has*_*Ali的帖子

使用ajax发送输入文件数据

html标记:

<input id="fileSelect" type="file" id="file" name="files[]" multiple="multiple" accept="image/*" />
Run Code Online (Sandbox Code Playgroud)

我用php上传多个文件.我想制作一组上传文件并使用ajax发送到服务器.如何制作多个选定文件的数组?

JavaScript的:

jQuery.ajax({
    url: 'insertfiles.php',
    type: "POST",
    data: {
      file: // array of selected files.
    },
    success: function(data){
    },
    error: function(data){
      alert( 'Sorry.' );
    }
});
Run Code Online (Sandbox Code Playgroud)

javascript php ajax jquery

6
推荐指数
2
解决办法
5万
查看次数

获取剩余时间并上传文件速度 - ajax jquery/js

jQuery.ajax
({
    url: ajaxurl,
    type: "POST",
    xhr: function()
    {
        var xhr = new window.XMLHttpRequest();
        xhr.upload.addEventListener( 'progress', function( e )
        {
            if( e.lengthComputable )
            {
                // Append progress percentage.
                var loaded = e.loaded;
                var total = e.total;
                var progressValue = Math.round( ( loaded / total ) * 100 );

                // Bytes received.
                jQuery( '.recievedValue' ).html( '' );
                jQuery( '.recievedValue' ).append( formatFileSize( loaded ) + ' / ' );

                // Total bytes.
                jQuery( '.totalValue' ).html( '' );
                jQuery( '.totalValue' ).append( formatFileSize( total …
Run Code Online (Sandbox Code Playgroud)

javascript ajax jquery

2
推荐指数
1
解决办法
5299
查看次数

匹配两个数组并返回与 php 匹配的值的计数

我有一个带有值的数组: $array_metaValue

Array ( [0] => php [1] => ajax [2] => my [3] => profile [4] => java )
Run Code Online (Sandbox Code Playgroud)

第二个数组包含: $search_res[$e]

php
ajax
Run Code Online (Sandbox Code Playgroud)

但问题是计数值总是错误的。应该是2。

            print_r( $array_metaValue);
            for($e=0;$e<=count($search_res);$e++){
            echo '<br>'.$search_res[$e].'<br>';
            echo '<pre>';

            $key = array_search($search_res[$e],$array_metaValue);

            if(!$key==0)
            {
                $count=$count+1;
            }
Run Code Online (Sandbox Code Playgroud)

$count 现在节省了 1。

php arrays

0
推荐指数
1
解决办法
3044
查看次数

标签 统计

ajax ×2

javascript ×2

jquery ×2

php ×2

arrays ×1