phpBB España Oficial, Soporte Internacional Oficial del sistema de foros phpBB en Español, extensiones, estilos, traducciones, guías, tutoriales, videos, redes sociales, webmaster.
https://www.phpbb-es.com/foro/
Código: Seleccionar todo
<?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://clubrenaultgt.com/foro/galeria/tmp/";
$varstat = "";
if ($_POST["action"] == "upload") {
if (is_uploaded_file($_FILES["imagen"]["tmp_name"])) {
$varname = $_FILES["imagen"]['name'];
$vartemp = $_FILES['imagen']['tmp_name'];
$vartype = mime_content_type($vartemp);
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>Subir imagen al ClubRenaultGT</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">ClubRenaultGT<img src="http://clubrenaultgt.com/foro/galeria/tmp/81f4addf36.jpg"></td>
</tr>
<tr>
<td class="text">Aloja tu imagen con formatos gif, bmp, jpeg, png, en nuestro servidor de ClubRenaultGT:</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="Subir Imagen" />
<input name="action" type="hidden" value="upload" /> </td>
</form>
</tr>
<?php if ($varstat == "ok") { ?>
<tr>
<td class="textinf"><strong>Confirmación:</strong><br>
Archivo publicado satisfactoriamente. Puedes utilizar las siguientes opciones para enlazarlo:<br>
<br>
<strong>Enlace BBCode para poner la imagen en el foro:</strong> <br>
<input name='txt1' type='text' value='[img]<?php echo $varpath; ?>[/img]' size='60'>
<br>
<strong>Enlace BBCode para crear diapositivas de todas las imagenes de tu post:</strong> <br>
<input name='txt1' type='text' value='[slideshow=grupo1]<?php echo $varpath; ?>,Sin titulo[/slideshow]' size='60'>
<br>
<strong>Enlace Directo: </strong><br>
<input name='txt2' type='text' value='<?php echo $varpath; ?>' size='60'></td>
</tr>
<?php } else { ?>
<?php if ($varstat != "") { ?>
<tr>
<td class="textinf"><strong>Error:</strong><br>
<?php echo $varstat; ?> </td>
</tr>
<?php } ?>
<?php } ?>
</table>
<?php if ($varstat == "ok") { ?>
<p align="center"><img src="tmp/<?php echo $varname; ?>"></p>
<?php } ?>
<?php if ($_GET['image'] != "") { ?>
<p align="center"><img src="tmp/<?php echo $_GET['image']; ?>"></p>
<?php } ?>
</body>
</html>
ator_18 escribió:He encontrado un codigo en internet que segun parece te crea la funcion de la que te hable, el codigo es el siguiente:
La fuente es es.php.net y su autor serkanyersen
Intentalo con ese codigo, ten encuenta que la funcion se llama get_mime y no mime_content_type, espero que te sea util.
Código: Seleccionar todo
<? /** * Tries to get mime data of the file. * @return {String} mime-type of the given file * @param $filename String */ function get_mime($filename){ preg_match("/\.(.*?)$/", $filename, $m); # Get File extension for a better match switch(strtolower($m[1])){ case "js": return "application/javascript"; case "json": return "application/json"; case "jpg": case "jpeg": case "jpe": return "image/jpg"; case "png": case "gif": case "bmp": return "image/".strtolower($m[1]); case "css": return "text/css"; case "xml": return "application/xml"; case "html": case "htm": case "php": return "text/html"; default: if(function_exists("mime_content_type")){ # if mime_content_type exists use it. $m = mime_content_type($filename); }else if(function_exists("")){ # if Pecl installed use it $finfo = finfo_open(FILEINFO_MIME); $m = finfo_file($finfo, $filename); finfo_close($finfo); }else{ # if nothing left try shell if(strstr($_SERVER[HTTP_USER_AGENT], "Windows")){ # Nothing to do on windows return ""; # Blank mime display most files correctly especially images. } if(strstr($_SERVER[HTTP_USER_AGENT], "Macintosh")){ # Correct output on macs $m = trim(exec('file -b --mime '.escapeshellarg($filename))); }else{ # Regular unix systems $m = trim(exec('file -bi '.escapeshellarg($filename))); } } $m = split(";", $m); return trim($m[0]); } } ?>
Tuve problemas al principio porque no me subia las imagenes en formato JPEG pero no se ni que e hecho ni porque pero ya funciona...Draude escribió:De momento ya esta arreglado, he utilizado el codigo que me has pasado, modificando esto:
Por esto:Código: Seleccionar todo
if(strstr($_SERVER[HTTP_USER_AGENT], "Windows")){ # Nothing to do on windows return ""; # Blank mime display most files correctly especially images. } if(strstr($_SERVER[HTTP_USER_AGENT], "Macintosh")){ # Correct output on macs
Sin comillas no funciona.Código: Seleccionar todo
if(strstr($_SERVER["HTTP_USER_AGENT"], "Windows")){ # Nothing to do on windows return ""; # Blank mime display most files correctly especially images. } if(strstr($_SERVER["HTTP_USER_AGENT"], "Macintosh")){ # Correct output on macs
Y esta:Por esta:Código: Seleccionar todo
$vartype = mime_content_type($vartemp);
Código: Seleccionar todo
$vartype = get_mime($varname);
Código: Seleccionar todo
<?php
$varrand = substr(md5(uniqid(rand())),0,10);
$varallw = array("image/bmp","image/gif","image/jpeg","image/jpg","image/pjpeg","image/png","image/x-png");
$varpath = "http://clubrenaultgt.com/foro/galeria/tmp/";
$varstat = "";
if ($_POST["action"] == "upload") {
if (is_uploaded_file($_FILES["imagen"]["tmp_name"])) {
$varname = $_FILES["imagen"]['name'];
$vartemp = $_FILES['imagen']['tmp_name'];
$vartype = get_mime($varname);
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";
}
}
}
?>
<?
/**
* Tries to get mime data of the file.
* @return {String} mime-type of the given file
* @param $filename String
*/
function get_mime($filename){
preg_match("/\.(.*?)$/", $filename, $m); # Get File extension for a better match
switch(strtolower($m[1])){
case "js": return "application/javascript";
case "json": return "application/json";
case "jpg": case "jpeg": case "jpe": return "image/jpg";
case "png": case "gif": case "bmp": case "jpg": return "image/".strtolower($m[1]);
case "css": return "text/css";
case "xml": return "application/xml";
case "html": case "htm": case "php": return "text/html";
default:
if(function_exists("mime_content_type")){ # if mime_content_type exists use it.
$m = mime_content_type($filename);
}else if(function_exists("")){ # if Pecl installed use it
$finfo = finfo_open(FILEINFO_MIME);
$m = finfo_file($finfo, $filename);
finfo_close($finfo);
}else{ # if nothing left try shell
if(strstr($_SERVER["HTTP_USER_AGENT"], "Windows")){ # Nothing to do on windows
return ""; # Blank mime display most files correctly especially images.
}
if(strstr($_SERVER["HTTP_USER_AGENT"], "Macintosh")){ # Correct output on macs
$m = trim(exec('file -b --mime '.escapeshellarg($filename)));
}else{ # Regular unix systems
$m = trim(exec('file -bi '.escapeshellarg($filename)));
}
}
$m = split(";", $m);
return trim($m[0]);
}
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Subir imagen al ClubRenaultGT</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">ClubRenaultGT<img src="http://clubrenaultgt.com/foro/galeria/tmp/81f4addf36.jpg"></td>
</tr>
<tr>
<td class="text">Aloja tu imagen con formatos gif, bmp, jpeg, png, en nuestro servidor de ClubRenaultGT:</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="Subir Imagen" />
<input name="action" type="hidden" value="upload" /> </td>
</form>
</tr>
<?php if ($varstat == "ok") { ?>
<tr>
<td class="textinf"><strong>Confirmación:</strong><br>
Archivo publicado satisfactoriamente. Puedes utilizar las siguientes opciones para enlazarlo:<br>
<br>
<strong>Enlace BBCode para poner la imagen en el foro:</strong> <br>
<input name='txt1' type='text' value='[img]<?php echo $varpath; ?>[/img]' size='60'>
<br>
<strong>Enlace BBCode para crear diapositivas de todas las imagenes de tu post:</strong> <br>
<input name='txt1' type='text' value='[slideshow=grupo1]<?php echo $varpath; ?>,Sin titulo[/slideshow]' size='60'>
<br>
<strong>Enlace Directo: </strong><br>
<input name='txt2' type='text' value='<?php echo $varpath; ?>' size='60'></td>
</tr>
<?php } else { ?>
<?php if ($varstat != "") { ?>
<tr>
<td class="textinf"><strong>Error:</strong><br>
<?php echo $varstat; ?> </td>
</tr>
<?php } ?>
<?php } ?>
</table>
<?php if ($varstat == "ok") { ?>
<p align="center"><img src="tmp/<?php echo $varname; ?>"></p>
<?php } ?>
<?php if ($_GET['image'] != "") { ?>
<p align="center"><img src="tmp/<?php echo $_GET['image']; ?>"></p>
<?php } ?>
</body>
</html>
Código: Seleccionar todo
$varallw = array("image/bmp","image/gif","image/jpeg","image/pjpeg","image/png","image/x-png");
Código: Seleccionar todo
<!-- IF not S_SHOW_DRAFTS and not $SIG_EDIT eq 1 -->
<div class="panel bg3" id="options-panel">
<div class="inner"><span class="corners-top"><span></span></span>
<fieldset class="fields1">
<div><label for="Subir imagen"><iframe src="http://imagenes.cowboysdelared.net/iframe.php" scrolling="no" allowtransparency="true" frameborder="0" width="140" height="35"></iframe></label></div>
Código: Seleccionar todo
<head>
<script language="javascript">
//Su explorador no soporta java o lo tiene deshabilitado; esta pagina necesita javascript para funcionar correctamente<!--
function abrir(direccion, pantallacompleta, herramientas, direcciones, estado, barramenu, barrascroll, cambiatamano, ancho, alto, izquierda, arriba, sustituir){
var opciones = "fullscreen=" + pantallacompleta +
",toolbar=" + herramientas +
",location=" + direcciones +
",status=" + estado +
",menubar=" + barramenu +
",scrollbars=" + barrascroll +
",resizable=" + cambiatamano +
",width=" + ancho +
",height=" + alto +
",left=" + izquierda +
",top=" + arriba;
var ventana = window.open(direccion,"venta",opciones,sustituir);
}
//-->
</script>
<input type="button" onclick="abrir('http://imagenes.cowboysdelared.net/galeria/imagehosting.php',0,0,0,0,0,0,0,600,455,60,20,1);" value="Subir imagen">
</head>
Código: Seleccionar todo
$varrand = substr(md5(uniqid(rand())),0,10);
$varallw = array("image/bmp","image/gif","image/jpeg","image/pjpeg","image/png","image/x-png");
$varpath = "http://imagenes.cowboysdelared.net/galeria/tmp/";
$varstat = "";
Código: Seleccionar todo
$varrand = substr(md5(uniqid(rand())),0,10);
$varallw = array("image/bmp","image/gif","image/jpeg","image/pjpeg","image/png","image/x-png");
$varpath = "http://foromus.com/imagehosting.php?image=";
$varstat = "";
$tam = 1073741824; //Tamaño del archivo en este en este ejemplo 1MB
if ($_POST["action"] == "upload") {
if (is_uploaded_file($_FILES["imagen"]["tmp_name"])) {
$varname = $_FILES["imagen"]['name'];
$vartemp = $_FILES['imagen']['tmp_name'];
$vartype = mime_content_type($vartemp);
if (in_array($vartype, $varallw) && $varname != "") {
$arrname = explode(".", $varname);
$varname = $varrand.".".$arrname[1];
if ((filesize($vartemp) < $tam)) {
if (copy($vartemp, "tmp/".$varname)) {
$varpath = $varpath.$varname;
$varstat = "ok";
} else {
$varstat = "Error al subir el archivo";
}
} else {
$varstat = "El archivo excede el maximo de 1MB permitido";
} else {
$varstat = "Archivo no valido";
}
}
}
Parse error: syntax error, unexpected T_ELSE in /home/clubrena/public_html/foro/galeria/imagehosting.php on line 29
¿alguien sabe como solucionarlo? gracias.