webForumDet fria alternativet

PHP upload MP3

1 svar · 465 visningar · startad av nummersju

nummersjuMedlem sedan aug. 2005198 inlägg
#1

Hej hej wF'are!
Jag har ett problem med ett uppladdningsscript.
Jag har provat med att ladda upp filer som jpg, waw och txt. Men jag kan inte ladda upp mp3-filer. Det händer ingenting med uppladdningen då...

Vad kan felet vara? Bifogar lite kod.

<?php
<?php
if(isset($_FILES['userfile']))
{

$upload_dir = 'uppladdat/';
$maxsize = (1024*10);
$password = 'abc';

if (isset($_POST['password'])  && $_POST['password'] != $password) {
	echo "Du har ingen åtkomst. Ledsen kisen :(\n";
}

elseif (empty($_FILES['userfile']['name'])) {
	echo "Du kan inte ladda upp luft heller.\n";
}

elseif ($_FILES['userfile']['size'] > $maxsize) {
	echo "The file is to big. \n";
}

else {

move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_dir.$_FILES['userfile']['name' ]);
echo "Filen har laddats upp :)";

}
}else{}

echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\" enctype=\"multipart/form-data\"/>\n";
echo "<input type=\"file\" name=\"userfile\"/><br/>\n";
echo "<input type=\"submit\" value=\"Upload file\"/ class=\"button\">\n";
echo "</form>\n";
?>
stevenetMedlem sedan juni 20001 251 inlägg
#2

Jag förmodar att du ökat max i ditt skript när du testat det?

http://se.php.net/manual/en/features.file-upload.common-pitfalls.php

*"The MAX_FILE_SIZE item cannot specify a file size greater than the file size that has been set in the upload_max_filesize ini-setting. The default is 2 Megabytes.

If a memory limit is enabled, a larger memory_limit may be needed. Make sure you set memory_limit large enough.

If max_execution_time is set too small, script execution may be exceeded by the value. Make sure you set max_execution_time large enough. "*

Du kan, om ditt webbhotell tillåter det, ändra dessa värden med ini_set.

Exempel:

<?php
// Ändra maxuppladdning-filstorleken till 5 Megabyte
ini_set("upload_max_filesize","5M");

?>
131 ms totalt · 3 externa anrop · v20260731065814-full.0e50b1ef
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
129 ms — hämta tråd, inlägg och bilagor (db)