我有以下代码示例upload3.php:
<html>
<head>
<title>PHP Form Upload</title>
</head>
<body>
<form method='post' action='upload3.php' enctype='multipart/form-data'>
Select a File:
<input type='file' name='filename' size='10' />
<input type='submit' value='Upload' />
</form>
<?php
if (isset($_POST['submit']))
{
echo "isset submit";
}
else
{
echo "NOT isset submit";
}
?>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
代码始终返回"NOT isset submit".为什么会这样?因为相同的脚本upload3.php调用自己?
CREATE TABLE counties(
idint(11) NOT NULL auto_increment,
countytinytext NOT NULL, PRIMARY KEY ( id) ) TYPE=MyISAM;
--
INSERT INTO `counties` VALUES (1, 'Alachua County');
Run Code Online (Sandbox Code Playgroud)
我在这里看到了一些模式。人们使用 `` 来包围字段名称并使用 '' 来包围值。真的吗?
或者这样做的主要原因是因为我们可以将代码放在文本文件中并导入到数据库中。
谢谢你
我想按如下方式进行文件大小验证.请查看此提案方法是否有意义.仅此部分应该有效.
1> After the user selects a file, I check whether the file has suffix as png, gif etc.
$("#myform").validate({
rules: {
fieldForUpload: {
required: true,
accept: "png|gif"
}
}
});
Run Code Online (Sandbox Code Playgroud)
2>然后我想使用aJax方法将文件上传到服务器以进行验证,甚至在用户单击提交按钮之前. http://docs.jquery.com/Plugins/Validation/Methods/remote#url
$("#myform").validate({
rules: {
fieldForUpload: {
required: true,
accept: "png|gif"
remote: "check-filesize.php"
}
}
});
Run Code Online (Sandbox Code Playgroud)
这是我的问题:
1>这种方法有效吗?换句话说,我可以一起验证fieldUpload与"accept"+"remote"吗?
2>我可以强制首先验证"接受",然后验证"远程"吗?
3>如何实现这种"远程"方法?仅供参考:我知道如何使用远程验证数据库中是否存在电子邮件.我是否必须获得一些不同的知识才能实现这一目标?
非常感谢