簡體   English   中英

PHP - 文件上傳[POST]:無法處理

[英]PHP - File Upload [POST]: Cannot process

我嘗試上傳圖片/文件時出錯。 圖像已上傳,但我始終存在此錯誤。

[08-Sep-2016 09:45:29 America/New_York] PHP Notice:  File Upload [POST]: Cannot process $_FILES[products_image_resize]['tmp_name'] in /home/www/boutique/includes/OM/Upload.php on line 73

第73行o上傳課程

if ( isset($_FILES[$this->_file]) ) {
        if ( isset($_FILES[$this->_file]['tmp_name']) && !empty($_FILES[$this->_file]['tmp_name']) && is_uploaded_file($_FILES[$this->_file]['tmp_name']) && ($_FILES[$this->_file]['size'] > 0) ) {
          $this->_upload = array('type' => 'POST',
                                 'name' => $_FILES[$this->_file]['name'],
                                 'size' => $_FILES[$this->_file]['size'],
                                 'tmp_name' => $_FILES[$this->_file]['tmp_name']);
        } else {
          trigger_error('File Upload [POST]: Cannot process $_FILES[' . $this->_file . '][\'tmp_name\']');
        }
      }

在我的類產品中:function getImage()

// load originale image
      $image = new Upload('products_image_resize', DIR_FS_CATALOG_IMAGES  . $dir_products_image, null, array('gif', 'jpg', 'png'));

      if ( $image->check() && $image->save() ) {
        $error = false;
      }

      if ( $error === false ) {
        $sql_data_array['image'] = $dir_products_image . $separator . $image->getFilename();
      } else {
        $sql_data_array['image'] = '';
        $OSCOM_MessageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'warning');
      }

// image
      $this->getImage();

在我的html文件中,我的表單

<form name="new_product" action="http://boutique/admin/index.php?Products&cPath=&pID=3&action=update_product" method="post" enctype="multipart/form-data">

我的考試

//print_r($_FILES[$this->_file]);
// Array ( [name] => [type] => [tmp_name] => [error] => 4 [size] => 0 ) - no files
//Array ( [name] => shopping-bag.png [type] => image/png [tmp_name] => /tmp/phpOg7mnD933577 [error] => 0 [size] => 933577 )  - files

print_r($_FILES[$this->_file]['tmp_name']); // 0 - no files
print_r($_FILES[$this->_file]['size']); // 0 - no file;

print_r($_FILES[$this->_file]['tmp_name']); // //tmp/phpOg7mnD933577 - files
print_r($_FILES[$this->_file]['size']); // /tmp/phpOg7mnD933577g - file;

線來測試

if ( isset($_FILES[$this->_file]['tmp_name']) && !empty($_FILES[$this->_file]['tmp_name']) && is_uploaded_file($_FILES[$this->_file]['tmp_name']) && ($_FILES[$this->_file]['size'] > 0) ) {

取而代之

if (!empty($_FILES[$this->_file]['tmp_name'])) { // works
   if (is_uploaded_file($_FILES[$this->_file]['tmp_name'])) { // File Upload [POST]: Cannot process $_FILES[products_image_resize]['tmp_name']
   if (($_FILES[$this->_file]['size'] > 0)) {  //works

在你的表格中,改變

<form name="new_product" action="http://boutique/admin/index.php?Products&cPath=&pID=3&action=update_product" method="post" enctype="multipart/form-data">

<form name="new_product" action="http://boutique/admin/index.php?Products&cPath=&pID=3&action=update_product" method="post" enctype="application/x-www-form-urlencoded">

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM