0

So, long story short, I have a LXC using a template of Ubuntu, where I'm running Apache2, and I have a little and simple code in /var/www/html/index.html.

The problem is I'm not sure I have the proper directory where I'm saving the uploaded images. Currently I'm keeping it in: /var/www/html/uploads.

I'm thinking maybe I should indicate something like: [SERVER_IP]:/var/www/html/uploads/.

But, yeah. I haven't figured out how to fix it.

edit: here's the code:

<?php
if(isset($_POST["submit"])){
   $filebasename = basename($_FILES['upfile']['name']);
   $desired_dir=$_SERVER['DOCUMENT_ROOT']. "uploads/";
   echo $desired_dir;
   $file_name = $_FILES['upfile']['name'];
   if (file_exists($desired_dir . $file_name)){
      $message = $file_name . "el archivo ya existe";
   } else {
      move_uploaded_file($_FILES["upfile"]["tmp_name"], $desired_dir . $file_name);
      $message = $file_name . "Cargado exitosamente"; 
   }
}
?>

<!DOCTYPE html>
<html>
<head>
<title>PHP Carga de Imagenes</title>
<body>
<h2>Carga de Imagenes</h2>
  <form action="" enctype="multipart/form-data" method="post" name="upl_frm">
    Selecciona la imagen <input type="file" name="upfile" />
    <input name="submit" type="submit" value="Cargar" />
    <?php 
    if(!empty($message)){
       echo $message; 
    } 
    ?>
  </form>
</body>
</html>
Lawrence Cherone
  • 46,049
  • 7
  • 62
  • 106
  • How to fix *what*? – zerkms Nov 23 '17 at 05:06
  • Well, It's not uploading anything. – Juan Cárdenas Nov 23 '17 at 05:07
  • You initially said you only have `index.html` - but then you've shown php code... – zerkms Nov 23 '17 at 05:30
  • @zerkms you can define `AddHandler application/x-httpd-php php` in your Apache config to handle html file extension through mod_php – Gordon Nov 23 '17 at 05:57
  • @Gordon I know that, but it's OP's responsibility to provide all the nuances of their configuration, so that we did not have to guess and assume. Check their other question: https://stackoverflow.com/questions/47445343/lxc-running-php-application It's not obvious whether they have php configured there or not at all. – zerkms Nov 23 '17 at 06:07
  • Not really a lxc issue so i've removed the tag. – Lawrence Cherone Nov 29 '17 at 20:28

0 Answers0