/    Sign up×
Community /Pin to ProfileBookmark

uploading songs in php

Hi, I’m trying to upload a song to a directory of my choice, and i found out how to upload an image and it worked by php code..i used the same code to do the same for songs, (upload songs) and it kinda freaked out and started giving me errors that don’t make sense..like the categoryID index doesnt exist but it does coz i posted it in an <input> tag inside a form whose action is the page thas supposed to upload the song..i used the same code to upload songs and images assuming that both are treated as files..it worked on images but not on songs..so if anyone could help me out i wud appreciate it..maybe songs have different php code to upload different from images..

$category=$_POST[‘categoryID’];
$name=$_
POST[‘name’];
$cat = $_POST[‘category’];
$singer = $_
POST[‘singer’];
$dir = $_FILES[‘directory’];

$target_path = “../../extras/music/”.$cat.”/”;
//echo $target_path;
$target_path = $target_path . basename($_FILES[‘directory’][‘name’]);
if(move_uploaded_file($_
FILES[‘directory’][‘tmp_name’], $target_path))
echo ‘<script>alert(“The Song has been uploaded”);</script>’;
else
echo ‘<script>alert(“problem!”);</script>’;
$song= $cat.”/”.basename( $_FILES[‘directory’][‘name’]);
//echo $song;*/
//if($song == ($cat.”/”)){
/*
echo ‘<script>alert( “The File Field is Empty!”);</script>’;}
echo ‘<script>location.href(“../index.php?addSong”);</script>’;

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @mazazino spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...