FTP upload with PHP, is not sending the image [closed]

3

Based on the code below I'm trying to send an image through the FTP protocol, but the file is not being sent, something tells me it's in the path of the file,

<?php

$arquivo = $_FILES["fileToUpload"]["name"];
$servidor = 'servidor';
$target_dir = "destino";
$con_id = ftp_connect($servidor) or die( 'Não conectou em: '.$servidor );
ftp_login( $con_id, 'usuario', 'senha' );

    if ($arquivo != "" && $_FILES != NULL){
            $uploadOk = 1;
        //echo $image_name;die;
        $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
        $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
        // Check if file already exists
        if (file_exists($target_file)) {
            echo "Sorry, file already exists.";die;
            $uploadOk = 0;
        }
        // Check file size
        if ($_FILES["fileToUpload"]["size"] > 500000) {
            echo "Sorry, your file is too large.";die;
            $uploadOk = 0;
        }
        // Allow certain file formats
        if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
        && $imageFileType != "gif" ) {
            echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";die;
            $uploadOk = 0;
        }
        // Check if $uploadOk is set to 0 by an error
        if ($uploadOk == 0) {
            echo "Sorry, your file was not uploaded.";die;
        // if everything is ok, try to upload file
        } else {
            ftp_put( $con_id, $target_dir.$arquivo['name'], $arquivo['tmp_name'], FTP_BINARY );
        }
    }
    
asked by anonymous 12.06.2015 / 22:54

0 answers