Php Wordpress用户图像上传
我正在开发自定义Wordpress会员网站。我已经为用户创建了一个插件来注册和登录,但我仍然坚持让用户上传他们的个人资料图片 这是我上传图像的表单,还有一些其他输入:Php Wordpress用户图像上传,php,wordpress,image,Php,Wordpress,Image,我正在开发自定义Wordpress会员网站。我已经为用户创建了一个插件来注册和登录,但我仍然坚持让用户上传他们的个人资料图片 这是我上传图像的表单,还有一些其他输入: <p class="form-row"> <input type="file" name="wp_custom_attachment"id="wp_custom_attachment" size="50" /> </p> 是否还需要添加一些其他内容才能正常工作?只有
<p class="form-row">
<input type="file" name="wp_custom_attachment"id="wp_custom_attachment" size="50" />
</p>
是否还需要添加一些其他内容才能正常工作?只有在元素具有正确的编码集并使用POST时,文件上载才会正常工作:
<form enctype="multipart/form-data" action="upload.php" method="POST">
如果您使用的是Apache Web Server,则可以在与脚本相同的目录中创建名为.htaccess的文件:
php_value upload_max_filesize 64M
php_value post_max_size 64M
您还可以将其放入处理上载的PHP文件中:
ini_set('post_max_size', '64M');
ini_set('upload_max_filesize', '64M');
您需要在对象的名称和ID之间添加一个空格,否则在使用除Chrome、Safari或Firefox以外的任何浏览器时,都会阻止上载正常工作:(文件上载需要name
attribute)
改为:
<input type="file" name="wp_custom_attachment" id="wp_custom_attachment" size="50" />
确保在名称和id之间添加空格。这可能会导致issue@NextLocal-名称和id之间的空格不会有问题。@WisdmLabs-事实上,除了chrome之外,它似乎在所有东西中都会引起问题。下面是概念证明:foo
现在运行在javascript控制台document.getElementById(“abc”)
如果它没有未定义,那么它就工作了。这里的问题是,因为它是一个表单元素,它需要有name
属性才能正常上传。它在firefox中就是这样工作的。因此,这可能只会在internet explorer上引起问题。
ini_set('post_max_size', '64M');
ini_set('upload_max_filesize', '64M');
<input type="file" name="wp_custom_attachment"id="wp_custom_attachment" size="50" />
<input type="file" name="wp_custom_attachment" id="wp_custom_attachment" size="50" />