admin管理员组文章数量:1334313
I am trying to make media_handle_upload() work but I keep getting 'Specified file failed upload test.' This is how I am testing it:
<html>
<body>
<form method="post" enctype='multipart/form-data'>
<input type="file" id="file_to_upload" name="dlkimage1" />
<?php
require($_SERVER['DOCUMENT_ROOT'].'/wp/wp-load.php');
require_once( ABSPATH.'wp-admin/includes/file.php' );
if ( isset($_FILES["dlkimage1"]) && !empty($_FILES["dlkimage1"]["tmp_name"]) )
$image_id = media_handle_upload(
$_FILES["dlkimage1"]["tmp_name"], // file
0, // ID of image post
array(), // post data (to overwrite some of the attachment)
array('test_form' => false) );
if ( is_wp_error($image_id) )
echo 'ERROR: ' . $image_id->get_error_message();
else
echo $image_id;
?>
<button class="button" id="updatepreview" type="submit" />Update Preview</button>
</form>
</body>
</html>
What am I missing?
本文标签: errorsmediahandleupload() returns Specified file failed upload test
版权声明:本文标题:errors - media_handle_upload() returns Specified file failed upload test 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742356351a2459490.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论