对同一表单的多个帖子请求

时间:2014-01-12 13:07:06

标签: php forms

我的表单为:<form action="test.php" method="post" name="testForm">

我在另一个文件“upload.php”中验证了图片上传,其中包含以下代码:

if (in_array($_FILES['myfile']['type'], $types)) {
if(filesize($_FILES['myfile']['tmp_name']) < $max_size) {
   $destination_path = getcwd().DIRECTORY_SEPARATOR."images".DIRECTORY_SEPARATOR;

因此,我可以通过任何方式调用upload.php文件,而无需从表单操作属性更改test.php文件并执行我的图像上传验证。

4 个答案:

答案 0 :(得分:1)

你可以使用

include('upload.php');

            OR

将函数副本用于test.php

答案 1 :(得分:1)

对于记录,使用jquery函数实际上会更好,该函数将表单提交到upload.php然后再提交给test.php。

答案 2 :(得分:0)

如果我找对你有很多方法。我建议在手册中阅读一下:

答案 3 :(得分:0)

如果您可以更改表单的HTML代码,可以发布到upload.php而不是test.php,然后从upload.php重新发布到test.php(例如,使用CURL)

相关问题