0

I'm not a php expert, but I must upload files from one server to another (server 2). In server 2, I have a shared folder with R/W for everyone (I granted that). But I can't upload the files, this is the part for uploading files:

    <?php


    if(isset($_FILES['image']))
    {
         $errors= array();
         $file_name = $_FILES['image']['name'];
         $file_size = $_FILES['image']['size'];
         $file_tmp = $_FILES['image']['tmp_name'];
         $file_type = $_FILES['image']['type'];
         $file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));


         if(empty($errors)==true) 
         {
         //$archivo = "uploads/".$file_name;
         $archivo = "\\\\192.168.0.63\\e$\\Sitios Web\\WSDocuware\\Files".$file_name;
         echo "Ruta archivo => ". $archivo."</br></br></br>";


         //move_uploaded_file($file_tmp,"uploads/".$file_name);
         move_uploaded_file($file_tmp,"\\\\192.168.0.63\\e$\\Sitios Web\\WSDocuware\\Files".$file_name);


         //$open = fopen("uploads/".$file_name, 'r');
         $open = fopen("\\\\192.168.0.63\\e$\\Sitios Web\\WSDocuware\\Files".$file_name, 'r');

         }

         print_r($_FILES);
}

?>

Where 192.168.0.63 is my ip server, I tried with: $archivo = "\\192.168.0.63\Sitios Web\WSDocuware\Files".$file_name; I tried with drive maping that folder, But I can't upload files. It works just in php server.

I hope anyone can help me please.

<html>
  <head>
<title>SUBIR ARCHIVO DW</title>
<link rel="stylesheet" type="text/css" title="Cool stylesheet" href="consumidor.css">

    <form action="" method="post" enctype="multipart/form-data">
        <table border="1" style="font-family:arial; font-size: 10px;" >
        <tr>
           <td>
              <input type = "file" name = "image" />      
           </td>
           <td>
              <input type = "submit" name = "btnCargar" value="1.- Cargar"/>   
           </td>
           <td>
                <input type="submit" name="btnData"  value="2.- Abrir"> 
           </td>
           <td> Fecha Desde
                <input id="datetimeD" type="date" name="doa">
           </td>
           <td> Fecha Hasta
                <input id="datetimeH" type="date" name="dob">
           </td>
           <td> 
                <input type="submit" name="btnExpr"  value="3.- Comparar">
           </td>
           <td>
                <ul>
                <li>Archivo Enviado: <?php echo $_FILES['image']['name'];  ?>
                <li>Tamano (bytes): <?php echo $_FILES['image']['size'];  ?>
                <li>Tipo Archivo: <?php echo $_FILES['image']['type'] ?>
                </ul>
           </td>
           <td>
                <a href="export-rpt.php">Exportar a Excel</a>   
           </td>
        </tr>


     </table>
    </form>

best regards

angel_neo
  • 333
  • 2
  • 5
  • 22
  • You have created a ftp account to send files to another server ? – miglio Mar 28 '18 at 22:23
  • Possible duplicate of [PHP: upload file from one server to another server](https://stackoverflow.com/questions/35311051/php-upload-file-from-one-server-to-another-server) – Javier S Mar 28 '18 at 22:25
  • There's hardly enough details in your question to diagnose anything (both Windows servers? user ids? etc). And it's commonly a permissions issue anyway, not a code problem. See also: [Read file on a network drive](//stackoverflow.com/q/14367687), [Php read file contents of network share file](//stackoverflow.com/q/5070545), [Cannot fopen network file (via UNC path) when running PHP in IIS](//stackoverflow.com/q/26027036) – mario Mar 28 '18 at 22:27
  • Thanks people, now... It's not my server, It's our customers' server. So I think It's dificult configure a ftp account. Yes, Both Windows Server , both are not in domain, users are diferent but I can copy, read, etc files on windows because The folder where I want upload files is shared (with all privileges for all users in the network) but when I try to do it with my application, this not works – angel_neo Mar 29 '18 at 01:47

0 Answers0