Sube.php
Código:
post.html<? if($_POST){ // Creamos la cadena aletoria $str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"; $cad = ""; for($i=0;$i<12;$i++) { $cad .= substr($str,rand(0,62),1); } // Fin de la creacion de la cadena aletoria $tamano = $_FILES [ 'file' ][ 'size' ]; // Leemos el tamaño del fichero $tamaño_max="50000000000"; // Tamaño maximo permitido if( $tamano < $tamaño_max){ // Comprovamos el tamaño $destino = 'uploaded' ; // Carpeta donde se guardata $sep=explode('image/',$_FILES["file"]["type"]); // Separamos image/ $tipo=$sep[1]; // Optenemos el tipo de imagen que es if($tipo == "gif" || $tipo == "pjpeg" || $tipo == "bmp"){ // Si el tipo de imagen a subir es el mismo de los permitidos, segimos. Puedes agregar mas tipos de imagen move_uploaded_file ( $_FILES [ 'file' ][ 'tmp_name' ], $destino . '/' .$cad.'.'.$tipo); // Subimos el archivo include('post.html'); // Incluimos la plantilla } else echo "el tipo de archivo no es de los permitidos";// Si no es el tipo permitido lo desimos } else echo "El archivo supera el peso permitido.";// Si supera el tamaño de permitido lo desimos } ?>
Código HTML:
La imagen fue enviada con exito.<br><strong>Datos:</strong><br> <ul> <li>Tipo <?=$tipo?></li> <li>Ubicasion http://www.midomini.com.ar/<?=$destino . '/' .$cad.'.'.$tipo?></li> </ul><br> <strong>Codigo HTML:</strong><br> <textarea name="html" id="html"><img src="http://www.midomini.com.ar/<?=$destino.'/'.$cad.'.'.$tipo?>"><br>Por www.midomini.com.ar</textarea><br> <img src="http://www.midomini.com.ar/<?=$destino.'/'.$cad.'.'.$tipo?>">
Código HTML:
<script> function ver(image){ document.getElementById('image').innerHTML = "<img src='"+image+"'>" } </script> <form action="sube.php" method="post" enctype="multipart/form-data"> Archivo: <input name="file" type="file" onChange="ver(form.file.value)"> <input name="submit" type="submit" value="Upload!"> </form><br> <span id="image"></span>
Cita:
y pues la verdad quisiera que me indiquen como soluconarlo, soy nuevo en este asunto... gracias de antemano... Warning: move_uploaded_file(uploaded/0UocPwYiwxa.gif) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/a4921920/public_html/Subir/sube.php on line 17
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpH01mOG' to 'uploaded/0UocPwYiwxa.gif' in /home/a4921920/public_html/Subir/sube.php on line 17
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpH01mOG' to 'uploaded/0UocPwYiwxa.gif' in /home/a4921920/public_html/Subir/sube.php on line 17