我只想使用php和jquery而不是ajax提交带有其他表单元素的图像(文件)
我的HTML在此我只想使用php和jquery而不是ajax提交带有其他表单元素的图像(文件),php,jquery,Php,Jquery,我的HTML在此 <body> <form id="myform" method="POST" action="formprocessing.php" enctype="multipart/form-data"> <input type="text" name="first_name" id="first_name" value=""><b/> <input type="text" name="last_name" id="last_na
<body>
<form id="myform" method="POST" action="formprocessing.php" enctype="multipart/form-data">
<input type="text" name="first_name" id="first_name" value=""><b/>
<input type="text" name="last_name" id="last_name" value=""><br />
Profile Image: <input name="image" id="image" type="file" /><br />
<input type="submit" name="formsubmit" id="formsubmit" onclick="return false" value="Submit">
</form>
<div id="result"></div>
</body>
我想显示的php页面如下所示
$name = $_POST['ufname'];
$lastname = $_POST['ulname'];
$img= $_FILES['ufiles']['name'];
echo $name;
echo $lastname;
echo $img;
我只想使用jquery和php提交图像和其他表单元素,我上面的代码工作了,但是图像文件没有上传,我怎么做 如果你想通过PHP上传图片,这里是你可以做到的
$extension = pathinfo($_FILES['ufiles']['name'], PATHINFO_EXTENSION);
$filename = '123_'.uniqid().'.'.$extension;
move_uploaded_file($_FILES['profile_image']['tmp_name'], '../path/'.$filename);
$.post是Ajax。可能与此问题重复:
$extension = pathinfo($_FILES['ufiles']['name'], PATHINFO_EXTENSION);
$filename = '123_'.uniqid().'.'.$extension;
move_uploaded_file($_FILES['profile_image']['tmp_name'], '../path/'.$filename);