title: Cant upload files from mobile version to classic version directory, same domain
body: <p>im currently having an issue with the upload of files from the mobile version of the site im currently working with, I think the issue is related to the fact that the mobile version files are outside the public_hmtl folder inside a folder named m, this was done like this because the m.site.com link wouldnt work otherwise, since im using the classic site folder to store all the media, the problem starts here:</p>
  
  <p>heres the path im working with:</p>
  
  <ul>
  <li>/</li>
  <li>/m</li>
  <li>/public_html</li>
  </ul>
  
  <p>the file in</p>
  
  <ul>
  <li>/m/user/fnc/upload.php</li>
  </ul>
  
  <p>is directed to save an img to </p>
  
  <ul>
  <li>/public_html/photos/users/</li>
  </ul>
  
  <p>here's a fragment of the code in upload.php
  for the first line, I use a redirect variable called $img that leads to the index of the classic version, that would be</p>
  
  <ul>
  <li>www.mysite.com/</li>
  </ul>
  
  <p>so</p>
  
  <pre><code>$URL = $img.'photos/users/';
  $NewFotoName = "misite_".$usuarioid."_".time().".jpg";
  
  if ($_SERVER['REQUEST_METHOD'] === 'POST') {
      $imagen = $_POST['Imagen'];
      if ( isset($_POST['Imagen']) ) {
          $image = base64_decode($imagen);
          $im = imagecreatefromstring($image);
          imagepng($im,$URL.$NewFotoName);
          imagedestroy($im);
  
          $query = "UPDATE Utenti SET foto = '$NewFotoName' WHERE id_utente = ".$usuarioid;
          $result = $mysqli-&gt;query($query);
          if(!$result){die($mysqli-&gt;error);}
          echo "index2.php";
                  die();
      } else {
          echo "index2.php";
                  die();          
      }
  } else {
      echo "index2.php";
                  die();
  }
  </code></pre>
  
  <p>and i call it from a file one folder above it called index2.php with this code:</p>
  
  <pre><code>$('.upload-result').on('click', function (ev) {
              $uploadCrop.croppie('result', {
                  type: 'canvas',
                  size: 'original'
              }).then(function (resp) {
                  $('#imagebase64').val(resp);
                  var imagen_cortada = $('#imagebase64').val();
                  var base64image = imagen_cortada;
                  var parametros = { "Imagen" : base64image };
                  $.ajax({
                      data: { "Imagen" : output },
                      url: 'fnc/upload.php',
                      method: 'POST', // or GET
                      success: function(msg) 
                      {
                          alert("Imagen subida con exito.");
                          alert(msg);
                      },
                      error: function (jqXHR, textStatus, errorThrown)
                      {
                          alert("Error al Subir la Imagen.");
                          alert(errorThrown);
                          window.location.replace(msg);
                      }
                  });
  </code></pre>
  
  <p>now when the form is submited I get a succes alert but in the "alert(msg);" I get an error that says</p>
  
  <blockquote>
    <p>imagepng(path/to/the/file.png): failed to open stream; no such file or
    directory in /home/mysite/m/user/fnc/upload.php</p>
  </blockquote>
  
  <p>So the name of the file gets saved into the database but the file doesnt.</p>
  
  <p>I appreciate any suggestions, excuse any spelling mistakes.</p>
  
  <p>//edit
  I found a work arround and moved the subdomaind directory inside public_html, had to learn a bit about the .htacces, it seems this way i will not have all those pesky permision problems</p>