2017-07-27 36 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.

相關問題