![triste](http://static.forosdelweb.com/fdwtheme/images/smilies/frown.png)
![Decabeza](http://static.forosdelweb.com/fdwtheme/images/smilies/decabeza.png)
Estoy tratando de copiar una imagen a un archivo usando php y me da este error:
Este es el fragmento del formulario donde selecciono la imagen:
Código HTML:
<form name="form1" enctype="multipart/form-data" action="Include/procesamiento/uploadImage.php" method="POST"> <div class="editar_i" style="display:none"> <input type="hidden" name="MAX_FILE_SIZE" value="2000000"> <input name="imageToUpload" id="imageToUpload" type="file" onchange="uploadImage();" size="30"> <iframe id="uploadedImage" name="uploadedImage" src="" style="width:200px; height:200px;" frameborder="0" marginheight="0" marginwidth="0"></iframe> </div> </form>
Le he quitado algunas cosas al script original porque lo estoy modificando para lo que estoy haciendo:
Código HTML:
var loadingHtml = "Loading..."; // this could be an animated image var imageLoadingHtml = "Image loading..."; var http = getXMLHTTPRequest(); //---------------------------------------------------------------- function uploadImage() { var uploadedImageFrame = window.uploadedImage; uploadedImageFrame.document.body.innerHTML = loadingHtml; // VALIDATE FILE var imagePath = window.uploadedImage.imagePath; alert(imagePath); if(imagePath == null){ //form1.oldImageToDelete.value = ""; // } else { //form1.oldImageToDelete.value = imagePath; // } form1.submit(); // } function getXMLHTTPRequest() { try { xmlHttpRequest = new XMLHttpRequest(); } catch(error1) { try { xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch(error2) { try { xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch(error3) { xmlHttpRequest = false; } } } return xmlHttpRequest; }
Código PHP:
function getExtension($str) {
$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}
$pathToUpload = "images/upload/temporal/"; //Carpeta de Destino
$fileFieldName = "imageToUpload"; //Campo con el nombre del archivo
$image = $_FILES[$fileFieldName]["name"]; // Nombre de la imagen
$nombre = stripslashes($_FILES[$fileFieldName]["name"]); // Le quito las / al nombre
$tamanio = $_FILES[$fileFieldName]["size"]; //Tamanio de la imagen
echo $tamanio."<br>";
//Validar extyension aqui
echo $_FILES[$fileFieldName]["tmp_name"];
$ext = getExtension($image); //Obtengo la extension con el formato: .extension
$ext = strtolower($ext);
$nombre_copia = "images/upload/temporal/".time().".". $ext; //el nombre completo del archivo origen
$copiada = copy($_FILES[$fileFieldName]["tmp_name"], $nombre_copia);
echo "<br>".$nombre_copia;
3193 (tamaño del archivo)
C:\wamp\tmp\php7825.tmp ($_FILES[$fileFieldName]["tmp_name"])
images/upload/temporal/1314477505.jpg (nombre copia)
Estuve revisando en C:\wamp\tmp\ y no hay ningun archivo php7825.tmp, no se si tenga que ver en algo,
en fin, les agradeceria infinitamente su ayuda para poder salir de esta pesadilla (
![ojotes](http://static.forosdelweb.com/fdwtheme/images/smilies/ojotes.png)