Código PHP:
<?php
include_once("config.inc.php");
global $host, $usuario, $contrasena, $database, $directorio, $extensiones;
$idcon = mysql_connect($host,$usuario,$contrasena);
mysql_select_db($database,$idcon);
$nombre_fichero = isset($_FILES['photo']['name'])?$_FILES['photo']['name']:null;
$nombre_temporal = isset($_FILES['photo']['tmp_name'])?$_FILES['photo']['tmp_name']:null;
$tipo_extension = isset($_FILES['photo']['type'])?$_FILES['photo']['type']:null;
if(!file_exists($directorio.$nombre_fichero)){
if(in_array($tipo_extension,$extensiones)){
if(!is_dir($directorio)){ mkdir($directorio,0777); } else { chmod($directorio,0777); }
$uploaded_file = move_uploaded_file($nombre_temporal,$directorio);
$pathtofile = $directorio.$nombre_fichero;
if($uploaded_file){
$query = "INSERT INTO imagenes(pathtoimage) VALUES('".$pathtofile."')";
$result = mysql_query($query) or die(mysql_error());
if($result){
header("main.php?ac=upload&err=t");
}else{
header("main.php?ac=upload&err=f");
}
}
}else{
header("main.php?ac=upload&err=ext");
}
}else{
header("main.php?ac=upload&err=file");
}
mysql_close($idcon);
?>
Cita:
Creo que es con los permisos de Windows pero no se como hacer para que esto me funcione correctamente. Uso Windows2003 Warning: move_uploaded_file(fotos/) [function.move-uploaded-file]: failed to open stream: Permission denied in d:\wamp\www\morgan\ac.php on line 19
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'D:\WINDOWS\TEMP\php21B.tmp' to 'fotos/' in d:\wamp\www\morgan\ac.php on line 19
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'D:\WINDOWS\TEMP\php21B.tmp' to 'fotos/' in d:\wamp\www\morgan\ac.php on line 19
Salu2