尝试将文件上载到Wordpress时出现502错误网关错误

时间:2017-07-27 21:03:59

标签: php wordpress file-upload

我很难弄清楚为什么我无法将文件上传到我的Wordpress Uploads文件夹。我试图在网上搜索无法解决任何问题。按下提交按钮后,我不断收到502 Bad gateway错误。注释区域用于最终将文件存储到数据库中。我需要在这一点上获得任何实际移动的文件。我创建了一个使用我的方法的快速和脏的小PHP脚本。如果有什么突出的请告诉我。

<?php
/* Template Name: testFileUpload */

/**
 * Created by PhpStorm.
* User: ccombs
* Date: 7/27/2017
* Time: 1:31 PM
*/

require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');

$file = $_FILES['uploaded_file'];
$fileoverride = array('test_form' => false);

/*//file upload for resume and error checking
if($_FILES['uploaded_file']['size'] != 0) {
       $externalDB->insert('emp_resume', array(
               'resume_name' => $file,
               'resume_type' => $file_type,
               'resume_size' => $file_size,
               'resume_contents' => $file_content,
               'applicantid' => $lastid
       ));
   }
*/
if(isset($_POST[('submitted')])) {

wp_handle_upload($file, $fileoverride);
}

?>
<?php get_header(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php echo var_dump($file); ?>
<? get_template_part( 'content-583', get_post_format() );?>
<form action="<?php the_permalink(); ?>" method="post"  id="app" 
enctype="multipart/form-data">
<table>
<tr>
    <td colspan="4" style="font-weight: bold">
        Attach your resume:
    </td>
</tr>
<tr>
    <td>
        <input type="file" name="uploaded_file">
    </td>
</tr>
    <tr>
        <td><input type="hidden" name="submitted" value="1">
            <input type="submit" value="Apply" class="btn">

        </td>

    </tr>
</table>
</form>
<?php endwhile; // end of the loop. ?>

<div><?php get_footer(); ?></div>

1 个答案:

答案 0 :(得分:0)

我联系了GoDaddy,这是我的托管服务提供商。他们告诉我他们将.docx文件上传到wordpress网站的“困难时期”。所以我测试了.doc,.pdf,.jpeg,.png和其他人上传得很好。每次我上传.docx文件时,服务器都会返回Bad Gateway 502.

相关问题