简体   繁体   English

通过javascript将表单值传递到另一个php类中

[英]Pass form values into another php class through javascript

I have a MyAccount page for my website which is going to have a form to allow the users to upload an image. 我的网站有一个MyAccount页面,该页面将具有一个允许用户上传图像的表格。

<from action='javascript:uploadFile'>
     <input type='file' name='Upload'>
</form>

What I would like to do is have it call another .php file like: 我想做的是让它调用另一个.php文件,例如:

<script type="text/javascript">
    function uploadFile()
    {
         addPhoto.php giving files $id and Upload (from the form)
    }

How can I achieve this without the user actually leaving the MyAccount page? 在用户不实际离开MyAccount页面的情况下如何实现?

You can use include or require within a PHP file. 您可以在PHP文件中使用includerequire

The include statement includes and evaluates the specified file. include语句包含并评估指定的文件。

You would need AJAX/jQuery to call it through JavaScript. 您将需要AJAX / jQuery通过JavaScript进行调用。

Documentation 文献资料

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM