Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/01/2008, 09:50
jpelectronic
 
Fecha de Ingreso: junio-2007
Mensajes: 27
Antigüedad: 16 años, 10 meses
Puntos: 0
No Carga Archivo Mp3 a Base de Datos!

Hola, les digo lo que me sucede, estoy tratando de grabar varios mp3 personalizado para cada usuario de mi pagina, realmente son cortos de tamaño, pero para probar quiero subir a la base de datos archivos de hasta 5Mb, inicialmente me aparecian errores de php por el limite de memoria y realice las siguientes modificaciones:


max_allowed_packet = 20M

max_execution_time = 30 ; Maximum execution time of each script, in seconds
memory_limit = 24M ; Maximum amount of memory a script may consume (8MB)

post_max_size = 20M

y el problema se fue, no me dio advertencias ni errores de ningun tipo.

al finalizar el script se muestra en pantalla el id del item, y siempre aparece ID=0, es dcir, no guarda nunca en la base de datos el archivo mp3, cuando grabo imagenes, o pdf, o archivos mas pequeños no me da ningun problema y graba todo bien. aqui les pongo el script a ver si alguien me puede hechar una mano.

<html>
<head><title>Store binary data into SQL Database</title></head>
<body>

<?php
// code that will be executed if the form has been submitted:

if ($submit) {

// connect to the database
// (you may have to adjust the hostname,username or password)

MYSQL_CONNECT("localhost","root","clavexxxpswrd");
mysql_select_db("binary_data");

$data = addslashes(fread(fopen($form_data, "r"), filesize($form_data)));

$result=MYSQL_QUERY("INSERT INTO binary_data (description,bin_data,filename,filesize,filetype) ".
"VALUES ('$form_description','$data','$form_data_name','$f orm_data_size','$form_data_type')");
if(!my_sql_error){
echo "error!";
}
else {
$id= mysql_insert_id();
print "<p>This file has the following Database ID: <b>$id</b>";}
MYSQL_CLOSE();

} else {

// else show the form to submit new data:
?>

<form method="post" action="<?php echo $PHP_SELF; ?>" enctype="multipart/form-data">
File Description:<br>
<input type="text" name="form_description" size="40">
<input type="hidden" name="MAX_FILE_SIZE" value="10000000">
<br>File to upload/store in database:<br>
<input type="file" name="form_data" size="100">
<p><input type="submit" name="submit" value="submit">
</form>

<?php

}

?>

</body>
</html>