2017-07-27 96 views
0

我有一个非常困难的时间搞清楚为什么我不能上传文件到我的Wordpress上传文件夹。我试图在网络上搜索,以解决这个问题。一旦按下提交按钮,我会一直收到502错误的网关错误。注释区域最终用于将文件存储到数据库中。我现在需要得到任何实际移动的文件。我创建了一个使用我的方法的快速和肮脏的小php脚本。如果有什么突出的请让我知道。502错误的网关错误,当试图上传文件到Wordpress

<?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> 
+0

尝试在服务器上的error.log文件中查找错误 – Oluwaseye

回答

0

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