upload and json

本文深入探讨了jQuery中序列化表单的方法,包括serialize()、serializeArray()和$.param(),并展示了如何处理上传文件和常规表单数据。同时,提供了解决使用元素点击调出对话框时遇到的访问权限问题的方案,以及通过覆盖div来解决透明度问题的技巧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

jquery submit serialized form
http://www.wangyexx.com/jquery/jc/1009.html

1. $("#form1").serialize(); // e.g. a=bob%3Dblog&b=1&c=1 autoencoding
2. $("#form1").serializeArray(); return json, php: json_decode
3. $.param({a:1,b:2,c:3}); // e.g. a=1&b=2&c=3


php dealing with uploaded file and normal form data

<?php

// 'fileData' is the fieldname in html for file tag
if(isset($_FILES['fileData']['name'])){
$target_path = "";

$target_path = $target_path . basename( $_FILES['fileData']['name']);

if(move_uploaded_file($_FILES['fileData']['tmp_name'], $target_path)) {
echo "{'status':'success'}";
} else{
echo "{'status':'error'}";
}

file_put_contents('normalFormData.txt', $_POST['-other normal fieldname-'].' \n '.$_POST['-other normal fieldname-']);
}



ps.
things about File beautifier
1. ie got access denied when using ele.click() to call out the dialogue box
2. use opacity:0; filter:alpha(opacity=0); instead to cover a div
3. make file following the cursor when mousemove on div
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值