upload and json

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

你可能感兴趣的:(upload and json)