Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/04/2006, 13:15
Avatar de floog
floog
 
Fecha de Ingreso: enero-2006
Mensajes: 191
Antigüedad: 18 años, 3 meses
Puntos: 2
Problemas al subir ficheros

Hola a todo el mundo,
la cuestion es que hemos hecho este script para subir ficheros. al ejecutarlo en el directorio raiz (http://localhost/paginaweb/) funciona estupendamente pero cuando lo ejecutamos en una carpeta(http://localhost/paginaweb/support/) no tira.... alguien sabria decirme por qué???

el error que nos reporta es:

Warning: Unable to create 'docs/824-2000.pdf': No such file or directory in c:\apache\htdocs\atlansur\support\upload_docs.php on line 30

Warning: Unable to move 'C:\WINDOWS\php103.tmp' to 'docs/824-2000.pdf' in c:\apache\htdocs\atlansur\support\upload_docs.php on line 30
Error uploading file

y el codigo es
Código PHP:
<?

//Modificación de la configuracion de php.ini del server
ini_set ("file_uploads","On");
ini_set ("max_execution_time","600");
ini_set ("max_input_time","600");
ini_set ("memory_limit","100M");
ini_set ("upload_tmp_dir","tmp/");
ini_set ("post_max_size","100M");
ini_set ("upload_max_filesize","100M");

// you can change this to any directory you want
// as long as php can write to it
$uploadDir 'docs/';


if(isset(
$_POST['upload']))
{
    
$fileName $_FILES['userfile']['name'];
    
$tmpName  $_FILES['userfile']['tmp_name'];
    
$fileSize $_FILES['userfile']['size'];
    
$fileType $_FILES['userfile']['type'];

    
// the files will be saved in filePath 
    
$filePath $uploadDir $fileName;

    
// move the files to the specified directory
    // if the upload directory is not writable or
    // something else went wrong $result will be false
    
$result    move_uploaded_file($tmpName$filePath);
    if (!
$result) {
        echo 
"Error uploading file";
        exit;
    }
    include 
'\include\db.php';

    if(!
get_magic_quotes_gpc())
    {
        
$fileName  addslashes($fileName);
        
$filePath  addslashes($filePath);
    }  

    
$query "INSERT INTO docs (imo, name, size, type, path ) ".
             
"VALUES ('$imo', '$fileName', '$fileSize', '$fileType', '$filePath')";

    
mysql_query($query) or die('Error, query failed : ' mysql_error());                    

    echo 
"<br>File uploaded<br>";
}        
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<head>
<title>Subir Informe Final</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../css/clients.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="contenedor_alt">

<form action="" method="post" enctype="multipart/form-data" name="uploadform">
  <table width="48%" border="0" cellpadding="1" cellspacing="1" class="box">
    <tr> 
      <td width="78"><p>
          <input type="hidden" name="MAX_FILE_SIZE" value="100000000">
                        Imo 
        </td>
      <td width="193" align="left"><input type="text" name="imo" id="imo" /></td>
      <td width="84" rowspan="2" align="center"><input name="upload" type="submit" class="box" id="upload" value="  Upload  "></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td align="left"><input name="userfile" type="file" class="text" id="userfile" /></td>
    </tr>
  </table>
</form>
</div>
</body>
</html>