elementz Posted March 31, 2006 Share Posted March 31, 2006 [code]<? //ob_start(); //the above line needs to be above ALL HTML and PHP (except for <?). //include("config.php"); //gets the config page, which connects to the database and gets the user's information //if ($logged[username]) //{ //checks to see if they are logged in switch($_GET[song]) { //this allows us to use one page for the entire thing default: break; case 'upload':echo ("<form action=\"song.php?song=add\" enctype=\"multipart/form-data\" method=\"post\"><br />Select file<input name=\"ufile\" type=\"file\" size=\"50\"><input type=\"submit\" name=\"Upload\" value=\"Upload\"></form>"); break;case 'add':$valid = array (".mp3",".wma");$type = strtolower(strstr($filename, '.'));if (!in_array($type, $valid)) {echo ("The submitted file was of invalid type.<br />");} $file_name = $HTTP_POST_FILES['ufile']['name'];$random_digit=rand(00000000,99999999);$new_file_name=$file_name.$random_digit;//set where you want to store files//in this example we keep file in folder upload //$new_file_name = new upload file name//for example upload file name cartoon.gif . $path will be upload/cartoon.gif$path= "songs/".$new_file_name;if($ufile !=none){if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path)){echo ("Successful<BR />"); //$new_file_name = new file name//$HTTP_POST_FILES['ufile']['size'] = file size//$HTTP_POST_FILES['ufile']['type'] = type of fileecho ("File Name :".$new_file_name."<BR />0");echo ("File Size :".$HTTP_POST_FILES['ufile']['size']."<BR />"); echo ("File Type :".$HTTP_POST_FILES['ufile']['type']."<BR />"); }else{echo ("Error");}}break; } echo("<br /><br /><a href=\"song.php?song=upload\">Add</a></b>");?>[/code]This is my code, but when I go to upload a song on it, it takes a while as if it is uploading it but then it comes up with the page "Cannot Connect To Server".Thankyou,Luke Quote Link to comment Share on other sites More sharing options...
elementz Posted March 31, 2006 Author Share Posted March 31, 2006 [!--quoteo(post=360267:date=Mar 31 2006, 04:34 PM:name=elementz)--][div class=\'quotetop\']QUOTE(elementz @ Mar 31 2006, 04:34 PM) [snapback]360267[/snapback][/div][div class=\'quotemain\'][!--quotec--][code]<? //ob_start(); //the above line needs to be above ALL HTML and PHP (except for <?). //include("config.php"); //gets the config page, which connects to the database and gets the user's information //if ($logged[username]) //{ //checks to see if they are logged in switch($_GET[song]) { //this allows us to use one page for the entire thing default: break; case 'upload':echo ("<form action=\"song.php?song=add\" enctype=\"multipart/form-data\" method=\"post\"><br />Select file<input name=\"ufile\" type=\"file\" size=\"50\"><input type=\"submit\" name=\"Upload\" value=\"Upload\"></form>"); break;case 'add':$valid = array (".mp3",".wma");$type = strtolower(strstr($filename, '.'));if (!in_array($type, $valid)) {echo ("The submitted file was of invalid type.<br />");} $file_name = $HTTP_POST_FILES['ufile']['name'];$random_digit=rand(00000000,99999999);$new_file_name=$file_name.$random_digit;//set where you want to store files//in this example we keep file in folder upload //$new_file_name = new upload file name//for example upload file name cartoon.gif . $path will be upload/cartoon.gif$path= "songs/".$new_file_name;if($ufile !=none){if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path)){echo ("Successful<BR />"); //$new_file_name = new file name//$HTTP_POST_FILES['ufile']['size'] = file size//$HTTP_POST_FILES['ufile']['type'] = type of fileecho ("File Name :".$new_file_name."<BR />0");echo ("File Size :".$HTTP_POST_FILES['ufile']['size']."<BR />"); echo ("File Type :".$HTTP_POST_FILES['ufile']['type']."<BR />"); }else{echo ("Error");}}break; } echo("<br /><br /><a href=\"song.php?song=upload\">Add</a></b>");?>[/code]This is my code, but when I go to upload a song on it, it takes a while as if it is uploading it but then it comes up with the page "Cannot Connect To Server".Thankyou,Luke[/quote]bump Quote Link to comment Share on other sites More sharing options...
elementz Posted March 31, 2006 Author Share Posted March 31, 2006 [!--quoteo(post=360272:date=Mar 31 2006, 05:54 PM:name=elementz)--][div class=\'quotetop\']QUOTE(elementz @ Mar 31 2006, 05:54 PM) [snapback]360272[/snapback][/div][div class=\'quotemain\'][!--quotec--]bump[/quote]help please :D Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted March 31, 2006 Share Posted March 31, 2006 Are you using a database? If you do can you show us the code use for:- connecting to database server- selecting database, and- when you query the database. Quote Link to comment Share on other sites More sharing options...
elementz Posted March 31, 2006 Author Share Posted March 31, 2006 [!--quoteo(post=360311:date=Mar 31 2006, 09:22 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Mar 31 2006, 09:22 PM) [snapback]360311[/snapback][/div][div class=\'quotemain\'][!--quotec--]Are you using a database? If you do can you show us the code use for:- connecting to database server- selecting database, and- when you query the database.[/quote]Nope, I am just testing the uploading script. Thats why I have commented out the user system. Could it be to do with the server?Thankyou,Luke Quote Link to comment Share on other sites More sharing options...
lpxxfaintxx Posted March 31, 2006 Share Posted March 31, 2006 Are you on a free shared hosting plan? They might not allow mp3s files. Quote Link to comment Share on other sites More sharing options...
elementz Posted March 31, 2006 Author Share Posted March 31, 2006 nope reseller. Could it still be the host? Cause the host doesn't allow me the chmod files to 777 only 755, could that be the problem? Quote Link to comment Share on other sites More sharing options...
bqallover Posted March 31, 2006 Share Posted March 31, 2006 [!--quoteo(post=360330:date=Mar 31 2006, 01:00 PM:name=elementz)--][div class=\'quotetop\']QUOTE(elementz @ Mar 31 2006, 01:00 PM) [snapback]360330[/snapback][/div][div class=\'quotemain\'][!--quotec--]nope reseller. Could it still be the host? Cause the host doesn't allow me the chmod files to 777 only 755, could that be the problem?[/quote]Sounds like that is your problem. If your upload directory is 755, then I think I'm right in saying your script can't write to it. I had a very similar problem on a test machine yesterday and chmod'ing to 777 fixed the script and allowed the uploads. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.