小编Sim*_*mdi的帖子

如何使用JavaScript和Ajax发送文件和输入字段来发送php脚本

请有人告诉我如何使用javascript做到这一点.因为我使用javascript和ajax加载将执行上传的页面,然后使用javascript和ajax将表单提交到php脚本

function AddMultipleContact(){
    var xmlhttp;
  if(window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp = new XMLHttpRequest();
  } else { // code for IE6, IE5
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
var url = "url.php";
var group = document.getElementById("select-input").value;
var file = document.getElementById('file-name').files;
var variables = "select-input="+group+"&file-name="+file;

xmlhttp.open("POST", url, true);
// Set content type header information for sending url encoded variables in the request
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

// Access the onreadystatechange event for the XMLHttpRequest object
xmlhttp.onreadystatechange = function() { …
Run Code Online (Sandbox Code Playgroud)

javascript php ajax

6
推荐指数
1
解决办法
581
查看次数

我想从数组中的所有元素中删除一个字母,并使用PHP将其替换为字符串.

$numbers = array("18339993993","18303839303");
foreach($numbers as $number) {
    $number = explode(",", $number);
    for($i = 0; $i <= count($number); $i++) {
        $number = substr($number,1, 10);
        echo $number;
}
Run Code Online (Sandbox Code Playgroud)

我想删除数组中每个元素中的第一个数字,并将其替换为"999"到数组中的所有元素.

I want my output to be like this for each element in the array:

$output[0] = "9998339993993"
$output[1] = "9998303839303"
Run Code Online (Sandbox Code Playgroud)

php

3
推荐指数
1
解决办法
119
查看次数

标签 统计

php ×2

ajax ×1

javascript ×1