Romanity
13-02-2007, 01:49 PM
When i run this script i get the following error:
Warning: copy(Don Maclean - Bye Bye Miss American Pie.mp3) [function.copy (http://www.ourhabbo.net/site/housekeeping/function.copy)]: failed to open stream: No such file or directory in /home/ourhabbo/public_html/site/housekeeping/add_song.php on line 38
Could not copy
The coding is:
<?
ob_start();
include("config.php");
?>
<html>
<head>
<title>Home</title>
<link href="housekeeping.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#ffffff" class='content'>
<b>Add Song</b><br>
Please fill in all fields, and then click Add Song to add the song to the database<br><br>
<?
if($logged[username] && $logged[username] == $owner1 || $logged[username] == $owner2 || $logged[username] == $siteman){
switch($_GET[act]){
default:
?>
<FORM ACTION="?act=add" METHOD="POST" enctype='multipart/form-data'>
Song Title: <i>[<b>Artist - Title</b>]</i><br><input type="text" name="title"><br><br>
Song:<br><input name='file' type='file' id='file'><br><br>
<input type='submit' name='send' value='Submit'>
</form>
<?
break;
case 'add':
$title = htmlspecialchars($_POST[title]);
$filename = $_FILES['file']['name'];
if( $filename !="" )
{
if(!file_exists("/home/ourhabbo/public_html/site/songs/" . $filename)){
$copy = copy ( $filename, "/home/ourhabbo/public_html/site/songs/" . $filename ) or die( "Could not copy" );
if($copy){
$query = mysql_query("INSERT INTO `songs` (id, title, song) VALUES('','$title','$filename')") or die ('Error during the execution of the MySQL query : ' . mysql_error());
echo("<meta http-equiv=\"Refresh\" content=\"2; URL=add_song.php\"/>You have succesfully added the song: $title<br><br><b>Please Wait...</b>");
}
}else{
echo("<meta http-equiv=\"Refresh\" content=\"2; URL=add_song.php\"/>The file already exists, and we cannot overwrite it");
}
}else{
echo("<meta http-equiv=\"Refresh\" content=\"2; URL=add_song.php\"/>You did not select a file to upload");
}
break;
}
}
?>
</body>
</html>
I cant see the error, all the directories in there exist and are 777
Warning: copy(Don Maclean - Bye Bye Miss American Pie.mp3) [function.copy (http://www.ourhabbo.net/site/housekeeping/function.copy)]: failed to open stream: No such file or directory in /home/ourhabbo/public_html/site/housekeeping/add_song.php on line 38
Could not copy
The coding is:
<?
ob_start();
include("config.php");
?>
<html>
<head>
<title>Home</title>
<link href="housekeeping.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#ffffff" class='content'>
<b>Add Song</b><br>
Please fill in all fields, and then click Add Song to add the song to the database<br><br>
<?
if($logged[username] && $logged[username] == $owner1 || $logged[username] == $owner2 || $logged[username] == $siteman){
switch($_GET[act]){
default:
?>
<FORM ACTION="?act=add" METHOD="POST" enctype='multipart/form-data'>
Song Title: <i>[<b>Artist - Title</b>]</i><br><input type="text" name="title"><br><br>
Song:<br><input name='file' type='file' id='file'><br><br>
<input type='submit' name='send' value='Submit'>
</form>
<?
break;
case 'add':
$title = htmlspecialchars($_POST[title]);
$filename = $_FILES['file']['name'];
if( $filename !="" )
{
if(!file_exists("/home/ourhabbo/public_html/site/songs/" . $filename)){
$copy = copy ( $filename, "/home/ourhabbo/public_html/site/songs/" . $filename ) or die( "Could not copy" );
if($copy){
$query = mysql_query("INSERT INTO `songs` (id, title, song) VALUES('','$title','$filename')") or die ('Error during the execution of the MySQL query : ' . mysql_error());
echo("<meta http-equiv=\"Refresh\" content=\"2; URL=add_song.php\"/>You have succesfully added the song: $title<br><br><b>Please Wait...</b>");
}
}else{
echo("<meta http-equiv=\"Refresh\" content=\"2; URL=add_song.php\"/>The file already exists, and we cannot overwrite it");
}
}else{
echo("<meta http-equiv=\"Refresh\" content=\"2; URL=add_song.php\"/>You did not select a file to upload");
}
break;
}
}
?>
</body>
</html>
I cant see the error, all the directories in there exist and are 777