move_uploaded_file()在Wordpress中不起作用

时间:2018-12-08 09:59:08

标签: php html wordpress

  

我正在使用PHP代码在Wordpess上工作,但是上载的文件没有通过move_uploaded_file()在上载文件夹中移动,也没有显示任何错误

<form action="" id="review_form" method="post" enctype="multipart/form-data" >
	<input type="file" name="yourfile" class="wp-form-control wp-file" aria-invalid="false">
</form>

$path =  "https://test.com/wp-content/themes/test/review_upload/";
$my_file =  basename($_FILES['yourfile']['name']);
$path1 = $path . $my_file;
$move = move_uploaded_file($_FILES['yourfile']['tmp_name'], $path1);

1 个答案:

答案 0 :(得分:1)

您应使用为move_uploaded_file指定目标而不是url的本地文件系统路径,请尝试以下代码。

$DirPath    =  wp_dir_path.'/uploads/2014/foldername/';