PHP和jQuery移动文件上传适用于桌面,但不适用于移动设备

时间:2014-07-23 20:46:48

标签: php jquery jquery-mobile file-upload

这是表单处理代码:

$name = $_POST['name'];
$score = $_POST['score'];
$screenshot = time();
$screenshot .= $_FILES['screenshot']['name']; // the name of the file to save
$target = GW_UPLOADPATH . $screenshot;
$screenshot_size = $_FILES['screenshot']['size'];
$screenshot_type = $_FILES['screenshot']['type'];

这是HTML中的表单(也包括jQuery):

<div data-role="page" id="main">
  <div data-role="header" style="text-align: left;font-size: 20px;">
        <?php if($mobile) echo $title; ?>
  </div><!-- /header -->
  <div data-role="content">
  <form enctype="multipart/form-data" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <div data-role="fieldcontainer" class="score">
    <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo GW_MAXUPLOADSIZE; ?>" />
    <label for="name">Name:</label>
    <input type="text" id="name" name="name" value="<?php if (!empty($name)) echo $name; ?>" /><br />
    <label for="score">Score:</label>
    <input type="number" id="score" name="score" value="<?php if (!empty($score)) echo $score; ?>" /><br />
    <label for="screenshot">Screen shot:</label>
    <input type="file" id="screenshot" name="screenshot" />
    <input type="submit" value="Add" name="submit" />
    </div><!-- /fieldcontainer -->
  </form>

如果我在台式计算机上提交,则上传处理正常,但当我在Android Chrome浏览器上访问该网站时,它会失败。使用错误报告:

注意:未定义的索引:第45行的C:\ Apache2.2 \ htdocs \ gw \ modtest.php中的屏幕截图提示:未定义的索引:C:\ Apache2.2 \ htdocs \ gw \ modtest.php中的屏幕截图47注意:未定义的索引:第48行的C:\ Apache2.2 \ htdocs \ gw \ modtest.php中的屏幕截图注意:未定义的索引:第52行的C:\ Apache2.2 \ htdocs \ gw \ modtest.php中的屏幕截图< / p>

我搜索了一个类似的问题并找到了一个,但唯一的答案是无益的“php是服务器端,而不是客户端。”任何帮助或解释都会非常有帮助。谢谢!

0 个答案:

没有答案
相关问题