V
V
vitaly_742022-04-09 04:02:02
PHP
vitaly_74, 2022-04-09 04:02:02

Why doesn't the rename method work?

Here is the docker container code:

FROM php:7.3-fpm
ARG COMPOSER_VER
ENV COMPOSER_VER ${COMPOSER_VER:-2.2.9}

WORKDIR /var/www/html

RUN apt-get update && apt-get install -y \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libpng-dev \
        libzip-dev \
        libxml2-dev \
        curl
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash
RUN apt-get -y install nodejs \
    git \
    unzip
#RUN npm --version
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
RUN docker-php-ext-install \
        soap \
        zip \
        bcmath \
        exif \
        gd \
        iconv \
        intl \
        mbstring \
        opcache \
        pdo_mysql \
        sockets

RUN pecl install xdebug \
    && docker-php-ext-enable xdebug

RUN curl -sS https://getcomposer.org/installer | \
            php -- --install-dir /usr/local/bin --filename composer --version ${COMPOSER_VER}

USER 1000

This is how I create the folder:
private function runtimeImagesDir(): string
    {
        $dir = Yii::getAlias('@runtime/images');
        if (!is_dir($dir)) {
            // Полный доступ для владельца, доступ на чтение и выполнение для других
            $old_umask = umask(0);
            mkdir($dir, 0775, true);
            umask($old_umask);
        }
        return $dir;
    }

and then I upload the image to this folder.
but then, when you try to transfer a file from this pack to a friend (which is also created), the application dies quietly without showing any error messages.
here is the code i am trying to move the file with:
//info результат работы pathinfo(); 
rename(
                $info['dirname'] . $info['basename'], //файл источник
                $this->folder() . '/' . $info['basename'] //то место куда нужно перенести
            )

I use wls2 + docker did
chown -R www-data:www-data path/to/project
Tell me what I'm doing wrong, what's wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vitaly_74, 2022-04-09
@vitaly_74

After reading my own question, I saw an error, it was:

rename(
                $info['dirname'] . $info['basename'], //файл источник
                $this->folder() . '/' . $info['basename'] //то место куда нужно перенести
            )

became (missing a slash):
rename(
                $info['dirname'] . '/' . $info['basename'],
                $this->folder() . '/' . $info['basename']
            );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question