Jump to content

Problem uploading Mp3 files


bynor

Recommended Posts

Hello there, i got a problem uploading Mp3 files, i use this Form:

 

<form enctype="multipart/form-data" method="post" name="carica" action="car1.php"><tr>

 

  <td><font color="#990000">Nome Canzone: </td><td><input type="text" name="use"></td></tr>

<tr><td><font color="#990000">Nome Artista: </td><td><input type="text" name="art"></td>

<tr>

<td> <input name="uploaded" type="file" /></td><td><input type="submit" value="Caricare canzone" name="car"></td></tr>

</form>

 

 

and this Php :

 

$target = "";

$target = $target . basename( $_FILES['uploaded']['name']) ;

$ok=1;

if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))

{ echo "il file ". basename( $_FILES['uploaded']['name']). " e stato caricato.";

}

else

{ echo "Errore nel caricamento.";

}

 

 

 

 

 

Now the problem is that the code WORKS for .jpg but DOESNT for mp3, the error i get is the following:

 

Notice: Undefined index: uploaded in E:\web\MusicStore1\car1.php  on line 18

 

Notice: Undefined index: uploaded in E:\web\MusicStore1\car1.php on line 20

 

where the lines are:

$target = $target . basename( $_FILES['uploaded']['name']) ;

and

if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))

respectivly

 

 

Thank you in advance :P

Link to comment
https://forums.phpfreaks.com/topic/205504-problem-uploading-mp3-files/
Share on other sites

You are probably exceeding the post_max_size setting, in which case the $_FILES array is empty and $_FILES['uploaded'] won't exist  - http://us3.php.net/manual/en/ini.core.php#ini.post-max-size

 

You must always validate data that comes from a visitor. In the case of an uploaded file you must test if $_FILES is not empty before attempting to process any of the uploaded file information. You must also test $_FILES['uploaded']['error'] to check for other errors that can occur (such as exceeding the upload_max_filesize) - http://us3.php.net/manual/en/features.file-upload.errors.php

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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.