Foros del Web » Programando para Internet » PHP »

DUPLICADO: problema con upload

Estas en el tema de DUPLICADO: problema con upload en el foro de PHP en Foros del Web. Amigos tengo un problema que me limita la carga de un mp3 solo de 2mb yo modifique mi archivo php.ini a 10mb pero igual me ...
  #1 (permalink)  
Antiguo 10/03/2015, 15:34
 
Fecha de Ingreso: marzo-2009
Mensajes: 117
Antigüedad: 15 años, 1 mes
Puntos: 2
DUPLICADO: problema con upload

Amigos tengo un problema que me limita la carga de un mp3 solo de 2mb

yo modifique mi archivo php.ini a 10mb pero igual me da el error y nada lo deje en 2mb



este es mi archivo file.php

<?php include('config.php');
if (isset($_GET['id']))

{
$id = $_GET['id'];
$query = mysql_query("SELECT * FROM archivos WHERE id='$id'");
while($row = mysql_fetch_assoc($query))
{
$enlace = $row['ID'];
$name = $row['Name'];
$url = $row['Url'];
$tamaño = $row['Tam'];
}

}
else

{
header('Location: 404.php');
}
function bytes2English($filesize)
{
if ($filesize<1048676)
RETURN number_format($filesize/1024,1) . " KB";
if ($filesize>=1048576 && $filesize<1073741824)
RETURN number_format($filesize/1048576,1) . " MB";
if ($filesize>=1073741824 && $filesize<1099511627776)
RETURN number_format($filesize/1073741824,2) . " GB";
if ($filesize>=1099511627776)
RETURN number_format($filesize/1099511627776,2) . " TB";
if ($filesize>=1125899906842624) //Currently, PB won't show due to PHP limitations
RETURN number_format($filesize/1125899906842624,3) . " PB";
}

?>
<html>
<head>
<title><?php echo $name ?> | Deckso Gamez</title>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="<?php echo $base ?>/css/tabla.css">
<link rel="stylesheet" type="text/css" href="<?php echo $base ?>/css/style.css">
<Script src="http://code.jquery.com/jquery-2.1.1-rc2.min.js" ></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<script src="script.js"></script>
</head>
<body>
<center>
<fieldset style="border: 1px solid #C8C8C8;width: 500;margin: 10;background: #FFF;">
<form style="margin:10px;" action="search.php" method="get">
<input style="width:350px; height:30px; text-align:center; font-family:fantasy" placeholder="Nombre de cancion o artista" type="text" name="id" id="buscar">
<input style="width:100px" type="submit" class="btn btn-success" value="Buscar">
</form>
</fieldset>
</center>
<div class="container-main">
aki
<h3><?php echo $name ?></h3>
<p><?php echo bytes2english($tamaño); ?> </p>

<object width="100%" height="24" type="application/x-shockwave-flash" data="<?php echo $base ?>player/player.swf">
<param name="movie" value="<?php echo $base ?>player/player.swf" />
<param name="flashvars" value="file=upload/<?php echo $url ?>?theme=light&autostart=true&screencolor=000000&b ackcolor=000000&frontcolor=ffffff&lightcolor=0774a f">
<param name="wmode" value="transparent" />
<param name="allowfullscreen" value="true"/>
<param name="allowScriptAccess" value="always" />
</object><br />

<center><a href="<?php echo $base ?>download?file=<?php echo $enlace ?>"><input type="image" src="<?php echo $base ?>imagenes/descarga-boton.png" /></a></center>
</div>



<p><a href="download.php?file=$url">prueba</a></p>






<center><table class="tbl1" cellpadding="2" cellspacing="1" width="500">
<tbody><tr class="hdr"><td colspan="2"><a href="/">Archivos subidos</a></td></tr>
<?php
$query = mysql_query("SELECT * FROM archivos ORDER BY ID DESC LIMIT 10");
while($row = mysql_fetch_assoc($query))
{

$id = $row['ID'];
$name = $row['Name'];
$tam = $row['Tam'];
$mb = bytes2english($tam);
//echo "<tr><td><a href='file.php?id=$id'>$name</a></td><td width='1%' nowrap='' align='right'> $mb </td></tr>";


echo "<tr><td><a href='download.php?file=$id'>$name</a></td><td width='1%' nowrap='' align='right'> $mb </td></tr>";
}


?>
</tbody></table></center>
</body>
</html>


index.php

</fieldset>
</center>
<div class="container-main">
<h1>Audio Upload</h1>
<p>By Deckso Gamez</p>

<form action="upload.php" method="post" id="myForm"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" class="btn btn-success" value="Upload Audio">
</form>

<div class="progress progress-striped active">
<div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0"
aria-valuemax="100" style="width: 0%">
<span class="sr-only">0% Complete</span>
</div>
</div>
<div style="background: #5CB85C; border-radius: 3px; color: #F0F0F0; font-size: 12pt; margin: 3px; text-align:center;" class="image"></div>
<div style="background: #FF2525; border-radius: 3px; color: #F0F0F0; font-size: 12pt; margin: 3px; text-align:center;" class="error"></div>
</div>
<center><table class="tbl1" cellpadding="2" cellspacing="1" width="500">
<tbody><tr class="hdr"><td colspan="2"><a href="/">Archivos subidos</a></td></tr>
aki
<?php
function bytes2English($filesize)
{
if ($filesize<1048676)
RETURN number_format($filesize/1024,1) . " KB";
if ($filesize>=1048576 && $filesize<1073741824)
RETURN number_format($filesize/1048576,1) . " MB";
if ($filesize>=1073741824 && $filesize<1099511627776)
RETURN number_format($filesize/1073741824,2) . " GB";
if ($filesize>=1099511627776)
RETURN number_format($filesize/1099511627776,2) . " TB";
if ($filesize>=1125899906842624) //Currently, PB won't show due to PHP limitations
RETURN number_format($filesize/1125899906842624,3) . " PB";
}
$query = mysql_query("SELECT * FROM archivos ORDER BY ID DESC LIMIT 10");
while($row = mysql_fetch_assoc($query))

{

$id = $row['ID'];
$name = $row['Name'];
$tam = $row['Tam'];
$mb = bytes2english($tam);
echo "<tr><td><a href='file.php?id=$id'>$name</a></td><td width='1%' nowrap='' align='right'> $mb </td></tr>";

//echo "<tr><td><a href='download.php?file=$id'>$name</a></td><td width='1%' nowrap='' align='right'> $mb </td></tr>";

}


?>
</tbody></table></center>
<br /><br /><br />
</body>
</html>

search.php

<?php include('config.php');
if (isset($_GET['id']))

{
$id = $_GET['id'];
$query = mysql_query("SELECT * FROM archivos WHERE id='$id'");
while($row = mysql_fetch_assoc($query))
{
$enlace = $row['ID'];
$name = $row['Name'];
$url = $row['Url'];
$tamaño = $row['Tam'];
}

}
else

{
header('Location: 404.php');
}
function bytes2English($filesize)
{
if ($filesize<1048676)
RETURN number_format($filesize/1024,1) . " KB";
if ($filesize>=1048576 && $filesize<1073741824)
RETURN number_format($filesize/1048576,1) . " MB";
if ($filesize>=1073741824 && $filesize<1099511627776)
RETURN number_format($filesize/1073741824,2) . " GB";
if ($filesize>=1099511627776)
RETURN number_format($filesize/1099511627776,2) . " TB";
if ($filesize>=1125899906842624) //Currently, PB won't show due to PHP limitations
RETURN number_format($filesize/1125899906842624,3) . " PB";
}
?>
<html>
<head>
<title><?php echo $id ?> | Deckso Gamez</title>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="<?php echo $base ?>/css/tabla.css">
<link rel="stylesheet" type="text/css" href="<?php echo $base ?>/css/style.css">
<Script src="http://code.jquery.com/jquery-2.1.1-rc2.min.js" ></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<script src="script.js"></script>
</head>
<body>
<center>
<fieldset style="border: 1px solid #C8C8C8;width: 500;margin: 10;background: #FFF;">
<form style="margin:10px;" action="search.php" method="get">
<input style="width:350px; height:30px; text-align:center; font-family:fantasy" placeholder="Nombre de cancion o artista" type="text" name="id" id="buscar">
<input style="width:100px" type="submit" class="btn btn-success" value="Buscar">
</form>
</fieldset>
</center>
<center><table class="tbl1" cellpadding="2" cellspacing="1" width="500">
<tbody><tr class="hdr"><td colspan="2"><a href="/">Resultados para <?php echo $id ?></a></td></tr>
<?php
$query = mysql_query("SELECT * FROM archivos WHERE Name LIKE '%$id%'");
while($row = mysql_fetch_assoc($query))
{

$id = $row['ID'];
$name = $row['Name'];
$tam = $row['Tam'];
$mb = bytes2english($tam);
//echo "<tr><td><a href='file.php?id=$id'>$name</a></td><td width='1%' nowrap='' align='right'> $mb </td></tr>";
echo "<tr><td><a href='download.php?file=$id'>$name</a></td><td width='1%' nowrap='' align='right'> $mb </td></tr>";

}


?>
<p><a href="index.php">Inicio</a></p>

</tbody></table></center>
</body>
</html>


upload.php

<?php

include('config.php');

// extenciones permitidas para subir
$allowedExts = array("mp3","MP3");
$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);

//checar si la extencion es valida
// subir al folder
//echo '0' si ay error
if ((($_FILES["file"]["type"] == "audio/mp3")
|| ($_FILES["file"]["type"] == "audio/MP3"))
&& in_array($extension, $allowedExts)) {
if ($_FILES["file"]["error"] > 0) {
echo "0";
} else {
$fileName = $_FILES["file"]["name"];
$fileType = $_FILES["file"]["type"];
$fileSize = $_FILES["file"]["size"];
$urlid = rand(10000,90000);
$urlid2 = rand(10000000000000000,900000000000000000);
$target = "upload/";
move_uploaded_file($_FILES["file"]["tmp_name"], $target. $urlid2. ".mp3" );
$url = "$urlid2.mp3";
mysql_query("INSERT INTO archivos VALUE ('$urlid', '$fileName', '$url', '$fileType', '$fileSize')");
echo $fileName ."<br> <a href='file?id=$urlid'>Ir al archivo</a> <br />";
}
} else {
echo "0";
}
  #2 (permalink)  
Antiguo 10/03/2015, 16:04
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: problema con upload

¿Otra vez el mismo tema?

¿Hay que volver a preguntarte lo mismo?

¿Por qué jamás le das formato al código que muestras?

¿Sigues recibiendo el mismo error que planteas en los mismos temas que abriste antes?

¿O en esta ocasión estamos obligados a ejecutar todo tu código mentalmente para decirte exactamente qué haces mal?

Temas duplicados:

http://www.forosdelweb.com/f18/uploa...a-2mb-1122761/
http://www.forosdelweb.com/f18/uploa...cador-1122625/
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #3 (permalink)  
Antiguo 10/03/2015, 17:14
Avatar de hhs
hhs
Colaborador
 
Fecha de Ingreso: junio-2013
Ubicación: México
Mensajes: 2.995
Antigüedad: 10 años, 10 meses
Puntos: 379
Respuesta: DUPLICADO: problema con upload

Quemen a este tipo en la hoguera por hereje
__________________
Saludos
About me
Laraveles
A class should have only one reason to change.

Etiquetas: html, mysql, select, tabla, upload
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 15:26.