Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

424
Visualizações
Upload a file to a virtual machine on apache server

I have a small problem which would be a great help.

I have a function in laravel that captures certain data and at the end with $ file-> move ($ virtual_machine_address, document) it is saved in the created folder. This locally works wonders. The code is referenced fromsubir archivos en laravel (API)

public function uploadFile(Request $request){

    /*Initializing variables in input*/
    $input = $request->all();

    /*rutas de carpeta*/
    $ruta_server = DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR.'172.xx.xx.xxx'.DIRECTORY_SEPARATOR.'Prueba'.DIRECTORY_SEPARATOR.'DOCUMENTOS'.DIRECTORY_SEPARATOR;

    /*Enter if file exist*/
    if($request->hasFile('file')){

        /*Modification in the name and extension*/
        $file = $request->file('file');
        $filename = $file->getclientOriginalName();
        $filename = pathinfo($filename, PATHINFO_FILENAME);
        $name_file = str_replace(" ", "_", $filename);
        $extension = $file->getClientOriginalExtension();

        /*Redacción o revisión*/
        if($input['posicion'] == 1){
            $picture = 'Redaccion('.$input['version'].')' . '-' . $name_file . '.' . $extension;
        }else{
            $picture = 'Revision('.$input['version'].')' . '-' . $name_file . '.' . $extension;
        }

        /*official root*/
        $ruta_oficial = $ruta_server.$input['id_carpeta'].DIRECTORY_SEPARATOR;

        /*create and uploadfile*/
        $file->move($ruta_oficial, $picture);

        return response()->json([
            "ok" => true,
            "error" => false,
            "data" => $picture
        ]);
    }else{
        return response()->json([
            "ok" => false,
            "error" => true,
            "mensaje" => "Error Detectado"
        ]);
    } 
}

I created a container in docker that simulates the apache server configuration where the project will be uploaded and when testing my function with postman, it doesn't work. Sending the error:

Symfony\Component\HttpFoundation\File\Exception\FileException: Unable to create the "//172.xx.xx.xxx/Prueba/DOCUMENTOS/100-2021/" directory. in file /opt/data/vendor/symfony/http-foundation/File/File.php on line 125

Along with 38 # more bugs.

My project versions: Laravel: 8.48.0 PHP: 8.0.7 Docker container: FROM php:8.0.7-apache (Linux) File server (172.xx.xx.xxx): Windows Virtual Server

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

This is my DockerFile

FROM php:8.0.7-apache

RUN apt-get update

# 1. paauetes dev
RUN apt-get install -y \
    git \
    zip \
    samba \
    smbclient \
    curl \
    sudo \
    unzip \
    libpq-dev \
    libzip-dev \
    libicu-dev \
    libbz2-dev \
    libpng-dev \
    libjpeg-dev \
    libmcrypt-dev \
    libreadline-dev \
    libfreetype6-dev \
    libsmbclient-dev \
    g++ \
    libaio1 wget && apt-get clean autoclean && apt-get autoremove --yes &&  rm -rf /var/lib/{apt,dpkg,cache,log}/ 



# 2. dir apache
ENV APACHE_HOME /var/www/html


# 3. mod_rewrite for URL rewrite and mod_headers for .htaccess extra headers like Access-Control-Allow-Origin-
RUN a2enmod rewrite headers

# 4. start with base php config, then add extensions
#RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"

RUN docker-php-ext-install \
    gd\
    bz2 \
    intl \
    iconv \
    bcmath \
    opcache \
    calendar \
#    mbstring \
#    pdo_mysql \
    zip 
    

# 5. composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
 

# ORACLE oci 
RUN mkdir /opt/oracle \
    && cd /opt/oracle     
    
ADD http://git.xxx.xxx/bxxxx.xxxx/media/raw/master/IC/instantclient-basic-linux.x64-19.5.0.0.0dbru.zip /opt/oracle
ADD http://git.xxx.xxx/bxxxx.xxxx/media/raw/master/IC/instantclient-sdk-linux.x64-19.5.0.0.0dbru.zip /opt/oracle

# Install Oracle Instantclient
RUN  unzip /opt/oracle/instantclient-basic-linux.x64-19.5.0.0.0dbru.zip -d /opt/oracle \
    && unzip /opt/oracle/instantclient-sdk-linux.x64-19.5.0.0.0dbru.zip -d /opt/oracle \
  #  && ln -s /opt/oracle/instantclient_19_5/libclntsh.so.19.1 /opt/oracle/instantclient_19_5/libclntsh.so \
    && ln -s /opt/oracle/instantclient_19_5/libclntshcore.so.19.1 /opt/oracle/instantclient_19_5/libclntshcore.so \
  #  && ln -s /opt/oracle/instantclient_19_5/libocci.so.19.1 /opt/oracle/instantclient_19_5/libocci.so \
    && rm -rf /opt/oracle/*.zip
    
ENV LD_LIBRARY_PATH  /opt/oracle/instantclient_19_5:${LD_LIBRARY_PATH}
    
# Install Oracle extensions
RUN echo 'instantclient,/opt/oracle/instantclient_19_5/' | pecl install oci8-3.0.1 \ 
      && docker-php-ext-enable \
               oci8 \ 
       && docker-php-ext-configure pdo_oci --with-pdo-oci=instantclient,/opt/oracle/instantclient_19_5,19.5 \
       && docker-php-ext-install \
               pdo_oci 

RUN mkdir -p /opt/data/public && \
    rm -r /var/www/html && \
    ln -s /opt/data/public $APACHE_HOME


    
WORKDIR $APACHE_HOME
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda