Jump to content

Recommended Posts

Добрый день! Прошу мне немного помочь/подсказать.

Работаю на OC 2.3.0.2. Хочу загрузить файл YML, но файл не проходит.

Вот код загрузки:

if ($this->request->server['REQUEST_METHOD'] == 'POST') {
			if(!empty($this->request->files) && $this->request->files['file']['name'][0] != '') {
				$extensions = 'xml';
				$path = DIR_UPLOAD.'yml/';
				if ($this->request->files['file']['name'] != '') {
					$ext = strtolower(pathinfo($this->request->files['file']['name'][0], PATHINFO_EXTENSION));
					if ($ext == $extensions) {
					  $newname = 'id' . $this->user->getId() . '.' . $ext;
					  $path = $path . $newname;
					  if (move_uploaded_file($this->request->files['file']['tmp_name'][0], $path)) {
						$data['success'] = $this->language->get('text_success');
					  } else {
						  $data['error'] = $this->language->get('error_upload');
					  }
					} else {
					  $data['error'] = $this->language->get('error_format');
					}
				}
			} else {
				$data['error'] = $this->language->get('error_no_file');
			}
		}

При обращении к $this->request->files выдает:

Array ( [file] => Array ( [name] => Array ( [0] => IPBernitskii.xml ) [type] => Array ( [0] => ) [tmp_name] => Array ( [0] => ) [error] => Array ( [0] => 1 ) => Array ( [0] => 0 ) ) )

не могу догнать почему tmp_name, type и прочее пусты

Share this post


Link to post
Share on other sites
4 минуты назад, ZeroHero сказал:

У вас ошибка при загрузке: размер файла больше, чем позволено в настройках php.

http://php.net/manual/ru/features.file-upload.errors.php

ох, вот это я не доглядел. думал xml-ки не много весят

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.