FoxLoghan escribió:Bueno ,, pues qui les dejo y explico como instalar y utilizar el Script que en un post anterior trato de explicarles "Maestro HTML" ...
VER DEMO // DESCARGAR SCRIPT COMPLETO
Bien ,, para empezar ,, El Script consta de 2 archivos y una carpeta..
Vease en la siguiente imagen
[contenido no disponible]
Bien , , pues comenzemos a crear los archivos
"imagehosting.php" (cambia la parte del codigo "http://TU-DIRECCION" , por la direcciond de tu sitio ..)
<?php
$varrand = substr(md5(uniqid(rand())),0,10);
$varallw = array("image/bmp","image/gif","image/jpeg","image/pjpeg","image/png","image/x-png");
$varpath = "http://TU-DIRECCION/imagehosting.php?image=";
$varstat = "";
if ($_POST["action"] == "upload") {
if (is_uploaded_file($_FILES["imagen"]["tmp_name"])) {
$varname = $_FILES["imagen"]['name'];
$vartemp = $_FILES['imagen']['tmp_name'];
$vartype = $_FILES['imagen']['type'];
if (in_array($vartype, $varallw) && $varname != "") {
$arrname = explode(".", $varname);
$varname = $varrand.".".$arrname[1];
if (copy($vartemp, "tmp/".$varname)) {
$varpath = $varpath.$varname;
$varstat = "ok";
} else {
$varstat = "Error al subir el archivo";
}
} else {
$varstat = "Archivo no valido";
}
}
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>PHP, Banco de imagenes </title>
<link href="cssupload.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="420" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="413" height="40" class="titulo">PHP, Hosting de imagenes </td>
</tr>
<tr>
<td class="text">Aloja gratuitamente tus imagenes:</td>
</tr>
<tr>
<form action="imagehosting.php" method="post" enctype="multipart/form-data">
<td height="50" valign="top" class="text">
<input name="imagen" type="file" class="casilla" id="imagen" size="35" />
<input name="enviar" type="submit" class="boton" id="enviar" value="Upload Image" />
<input name="action" type="hidden" value="upload" /> </td>
</form>
</tr>
<?php if ($varstat == "ok") { ?>
<tr>
<td class="textinf">Confirmación:
Archivo publicado satisfactoriamente. Puedes utilizar las siguientes opciones para enlazarlo:
Enlace HTML:
<input name='txt1' type='text' value='[contenido no disponible]' size='60'>
Enlace Directo:
<input name='txt2' type='text' value='<?php echo $varpath; ?>' size='60'></td>
</tr>
<?php } else { ?>
<?php if ($varstat != "") { ?>
<tr>
<td class="textinf">Error:
<?php echo $varstat; ?></td>
</tr>
<?php } ?>
<?php } ?>
</table>
<?php if ($varstat == "ok") { ?>
<p align="center">[contenido no disponible]</p>
<?php } ?>
<?php if ($_GET['image'] != "") { ?>
<p align="center">[contenido no disponible]</p>
<?php } ?>
</body>
</html>
"cssupload.css" (puedes modificar el codigo para darle el aspecto que deseas)
.titulo {
font-family: "Trebuchet MS", Verdana;
font-size: 18px;
font-weight: bolder;
color: #990000;
text-decoration: none;
border-top-width: 1px;
border-bottom-width: 1px;
border-top-style: solid;
border-bottom-style: solid;
border-top-color: #D4D0C8;
border-bottom-color: #D4D0C8;
text-align: left;
padding-left: 30px;
}
.casilla {
font-family: "Trebuchet MS", Verdana;
font-size: 12px;
font-weight: normal;
color: #666666;
text-decoration: none;
border: 1px solid #D4D0C8;
}
.boton {
font-family: "Trebuchet MS", Verdana;
font-size: 12px;
font-weight: normal;
color: #000000;
text-decoration: none;
vertical-align: middle;
}
.subtitulo {
font-family: "Trebuchet MS", Verdana;
font-size: 16px;
font-weight: bolder;
color: #999999;
text-decoration: none;
text-align: left;
padding-left: 30px;
border-top-width: 1px;
border-top-style: solid;
border-top-color: #D4D0C8;
}
.infsub {
font-family: "Trebuchet MS", Verdana;
text-decoration: none;
border-top-width: 1px;
border-top-style: solid;
border-top-color: #D4D0C8;
}
.text {
font-family: "Trebuchet MS", Verdana;
font-size: 12px;
font-weight: normal;
color: #999999;
text-decoration: none;
text-align: left;
padding-left: 30px;
padding-top: 10px;
}
.link {
font-family: "Trebuchet MS", Verdana;
font-size: 12px;
font-weight: bolder;
color: #990000;
text-decoration: none;
text-align: center;
}
a.link:hover {
font-family: "Trebuchet MS", Verdana;
font-size: 12px;
font-weight: bolder;
color: #990000;
text-decoration: underline;
text-align: center;
}
.linkli {
font-family: "Trebuchet MS", Verdana;
font-size: 12px;
font-weight: normal;
color: #0000C0;
text-decoration: none;
}
a.linkli:hover {
font-family: "Trebuchet MS", Verdana;
font-size: 12px;
font-weight: normal;
color: #0000C0;
text-decoration: underline;
}
img {
border: 1px solid #D4D0C8;
padding: 5px;
margin: 5px;
}
.textinf {
font-family: "Trebuchet MS", Verdana;
font-size: 12px;
font-weight: normal;
color: #999999;
text-decoration: none;
text-align: left;
padding-left: 30px;
padding-top: 10px;
border-top-width: 1px;
border-top-style: solid;
border-top-color: #D4D0C8;
}
Bien ,, la ultima parte del Script es Crear una carpeta que llamaremos "tmp" y a la cual le daremos permisos 777 , una vez que la hayamos subido al Host
******************************
Ahora solo subimos nuestros dos archivos y la carpeta a nuestro Host ,, Damos permisos de escritura 777 a la carpeta y listo !!!!
Tu Host de imagenes esta listo para usarse ........
http://TU-DIRECCION/imagehosting.php
******************************
VER DEMO // DESCARGAR SCRIPT COMPLETO
hola amigos! ¡No sabeis cuanto nos auydais con este foro eeH!
miren mi problema es que en mi servidor ya tiene ellos un archivo con el nombre "tmp" entonces el archivo tmp que yo creé no hace nada,cuando me fui a probar si me funciona o no,resulta que todo funciona menos eso,que me niega a poner mas archivo en el tmp.¿y me preguntaba si sabe alguien como se hace si quieres cambiar el nombre de archivo en el php, es decir el nombre del directorio donde quieres que aparezcan los archivos de imagenes? por ejemplo si quieres cambiar ese tmp por otro nombre de archivo?muchas gracias