表单提交数据 没有action 没有enctype
要提交图片 csv文件的上传 表单里面只有id 很name 这样可以实现文件上传吗。还不能用submit 只能用button的js提交
<form id="xx" name="xx">
<input type="file" name="usbmitfile">
<input type="button" onclick="xx()">
</form>
//能实现么
------解决方案--------------------直接用js赋action属性,然后提交!
------解决方案--------------------你说呢???
------解决方案--------------------可以用远程提交
a.php 发送页面
<?php
//远程提交数据$data(不需要登录)
function func_DataPost($strSumbitPage, $data, $Ref_url = "", $strUserAgent = "", $arrHttpHeader="", $cookie_jar ="") //远程提交数据$data(不需要登录)
{
// $data = array(
// "file1" => "@C:\\wbiaoarticle\\13575672507.jpg",
// "te_Name" => time(),
// "te_password" => "ab--__==##%^cdziy!!><",
// "su_deal" => "开始处理",
// );
$strUserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1";
// $arrHttpHeader = array('X-FORWARDED-FOR:8.8.8.8', 'CLIENT-IP:192.168.8.8'); //构造IP
if(!is_file($cookie_jar))
{
$cookie_jar = dirname(__file__)."\\cookie_mytem.txt";
if(is_file($cookie_jar))
unlink($cookie_jar); //先清除cookie
}
//提交
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $strSumbitPage);
if(!empty($Ref_url))
curl_setopt($ch, CURLOPT_REFERER, $Ref_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_jar); //cookie存放位置
// if(count($arrHttpHeader))
curl_setopt($ch, CURLOPT_HTTPHEADER, $arrHttpHeader); //构造IP
curl_setopt($ch, CURLOPT_HEADER,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if(!empty($strUserAgent)) //用户代理
curl_setopt($ch, CURLOPT_USERAGENT, $strUserAgent); //设置UA
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$str = curl_exec($ch);
curl_close($ch);
if(strlen($str) == 0)
return 0;
return $str;
}
$data = array(
"file1" => "@C:\\wbiaoarticle\\13575672507.jpg",
"te_Name" => time(),
"te_password" => "ab--__==##%^cdziy!!><",
"su_deal" => "开始处理",
);
func_DataPost($strUrl, $data);
?>
接收页面
b.php
<?php
$strPath = "1.jpg";
//生成文件
if (move_uploaded_file($_FILES['file1']['tmp_name'], $strPath))
{
echo "$strPath have been created<br/>";
return 1;
}
?>