Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/242.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我只想使用php和jquery而不是ajax提交带有其他表单元素的图像(文件)_Php_Jquery - Fatal编程技术网

我只想使用php和jquery而不是ajax提交带有其他表单元素的图像(文件)

我只想使用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

我的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_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);