Hi all i am trying to make my upload system remove spaces of uploaded files in a file name of a uploaded file this is my code i have atm
?>
<table>
<form enctype="multipart/form-data" action="" method="post">
<tr>
<th>Song Name:</th>
<th><input type="text" name="songname"></th>
</tr>
<tr>
<th>Artist</th>
<th><input type="text" name="artist"></th>
</tr>
<tr>
<th>Music File</th>
<th><input type="file" name="userfile"></th>
</tr>
<tr>
<th><input type="submit" name="upload" value="Upload"></th>
</tr>
</form>
</table><?php
//
if(isset($_POST['upload']))
{
$userfile=$_FILES['userfile'];
$songname=$_POST['songname'];
$artist=$_POST['artist'];
$songname2=$_FILES['userfile']['name'];
if($userfile || $songname || $artist)
{
//
$path = "mp3/";
$path2="mp3/".$_POST['userfile']['name']."";
$max_size = 20000000;
if(!isset($HTTP_POST_FILES['userfile']))
{
exit;
}
if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name']))
{
if ($HTTP_POST_FILES['userfile']['size']>$max_size)
{
echo "The file is too big<br>\
";
exit;
}
if (($HTTP_POST_FILES['userfile']['type']=="audio/mpeg"))
{
if (file_exists($path . $HTTP_POST_FILES['userfile']['name']))
{
echo "The file already exists<br>\
";
exit;
}
$res = copy($HTTP_POST_FILES['userfile']['tmp_name'], $path .
$HTTP_POST_FILES['userfile']['name']);
if (!$res)
{
echo "upload failed!<br>\
";
exit;
}
else
{
include("dbconnect.php");
$rQuery="INSERT into music values('','$songname','$path$songname2','$artist')";
$rs=mysqli_query($con,$rQuery);
if(!$rs)
{
echo "Error".mysqli_error($con);
}
else
{
echo "upload sucessful<br>\
The File has been placed in the MP3 folder<br/>";
echo "File is ".$path2."".$songname2."";
}
}
}
else
{
echo "Wrong file type<br>\
";
exit;
}
}
//
}
}
That is what i have so far is there any other way i can do that removing spaces of file names of files uploaded?