Jump to content
Programar

Upload mp3

Recommended Posts

Programar

Boas, eu tenho este código php mas só faz upload de arquivos mp3 com menos de 1Mb.

Como é que faço para aumentar o tamanho???

index.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Música</title>
</head>
<body>
<form name="upload" action="upload.php" method="post" enctype="multipart/form-data">
<table>
<tr>
    <td>Música:</td><td><input type="file" name="file"></td>
</tr>
<tr>
    <td></td>
    <td><input type="submit" name="submit" value="upload"></td>
</tr>
</table>
</form>
</body>
</html>

upload.php

<?php
$need_auth = true;
if(($_FILES["file"]["type"] == "audio/mp3") && ($_FILES["file"]["size"] < 10485760))
{
if($_FILES["file"]["error"] > 0)
{
    echo "Erro: " .$_FILES["file"]["error"]. "<br /><br />";
}
else
{
    if(file_exists("musicas/" .$_FILES["file"]["name"]))
    {
    echo "Musica existente.";exit;
    }
    else
    {
    $addFile = $_FILES["file"]["name"];
    move_uploaded_file($_FILES["file"]["tmp_name"],"musicas/" .$addFile);
    print_r($_POST["file"]["name"]);
echo "Upload feito com sucesso.
";exit;
    }
}
}
else
{
echo "Erro de upload";
}
?>

obg...

Edited by thoga31
GeSHi

Share this post


Link to post
Share on other sites
Virneto

Dizes 1 mb ou 10 Mb?

se for 10Mb é porque o teu código está a rejeitar tamanhos superiores a 10 Mb=> (["size"] < 10485760))

Se for 1 Mb, verifica a configuração no php.ini()


"Que inquieto desejo vos tortura, Seres elementares, força obscura? Em volta de que ideia gravitais?" >> Anthero de Quental

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Linuxando.com | ...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.