pjc2003 Posted April 2, 2007 Share Posted April 2, 2007 hi, Im trying to design a webpage form in php that allows uploading of three mp3 files to a folder on my server. The webpage should convert the name of each mp3 file uploaded to 1.mp3 , 2.mp3 and 3.mp3 and whenever a new song is uploaded it should replace whatevers in the folder on the server, im totally stuck as where to begin.. Any help would be great, Many thanks, Pete. Quote Link to comment Share on other sites More sharing options...
only one Posted April 2, 2007 Share Posted April 2, 2007 try this, youl have to make a folder called uploads, in the folder where this page is saved <?php $path = "uploads/"; if (!isset($HTTP_POST_FILES['userfile'])){ echo " <FORM ENCTYPE=multipart/form-data ACTION='' METHOD=POST> <p>The file:<br> <INPUT TYPE=file NAME=userfile> </p> <p> <INPUT TYPE=submit VALUE=Upload> </p> </FORM> "; }else{ if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) { if (($HTTP_POST_FILES['userfile']['type']=="audio/mp3")")) { if (file_exists($path . $HTTP_POST_FILES['userfile']['name'])) { echo "<font color=red>Error</font>! The file already exists, try calling your file a different name.<br><FORM ENCTYPE=multipart/form-data ACTION='' METHOD=POST> <p>The file:<br> <INPUT TYPE=file NAME=userfile style='border: 1px solid #222222; background-color: #111111; color: #888888'> </p> <p> <INPUT TYPE=submit VALUE=Upload style='border: 1px solid #222222; background-color: #111111; color: #888888'> </p> </FORM>"; }else{ $res = copy($HTTP_POST_FILES['userfile']['tmp_name'], $path . $HTTP_POST_FILES['userfile']['name']); if (!$res) { echo "upload failed!<br>"; exit; } else { echo "upload sucessful<br><br>"; } echo "File Name: ".$HTTP_POST_FILES['userfile']['name']."<br>"; echo "File Path: <a href=uploads/".$HTTP_POST_FILES['userfile']['name']." TARGET=_BLANK>uploads/".$HTTP_POST_FILES['userfile']['name']."</a><br>"; echo "File Size: ".$HTTP_POST_FILES['userfile']['size']." bytes<br>"; echo "File Type: ".$HTTP_POST_FILES['userfile']['type']."<br>"; echo "<img src=uploads/".$HTTP_POST_FILES['userfile']['name']."><br>"; }}}} ?> Quote Link to comment Share on other sites More sharing options...
pjc2003 Posted April 8, 2007 Author Share Posted April 8, 2007 hi there, Ive created the uploads folder but its throwing up a syntax error Parse error: syntax error, unexpected '"' in upload.php on line 20 any ideas? thanks for your reply by the way its much appreciated, Pjc. Quote Link to comment Share on other sites More sharing options...
HaLo2FrEeEk Posted April 8, 2007 Share Posted April 8, 2007 I have an idea, look at line 20 and find the error, we are here to help, not coddle, you need to do some stuff yourself. I know where the error is, but I need you to find it yourself. Quote Link to comment Share on other sites More sharing options...
pjc2003 Posted April 8, 2007 Author Share Posted April 8, 2007 on line 20 i thought it was missing a " if (($HTTP_POST_FILES['userfile']['type']=="audio/mp3")")) { so ive changed it to : if ("($HTTP_POST_FILES['userfile']['type']=="audio/mp3")")) { but it now comes up with: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /usr/home/longnines/public_html/fyp/upload.php on line 20 Im quite new to PHP so just after some guidance not people to do work for me. Thanks. Quote Link to comment Share on other sites More sharing options...
pjc2003 Posted April 8, 2007 Author Share Posted April 8, 2007 its ok i have it working now thanks Quote Link to comment Share on other sites More sharing options...
HaLo2FrEeEk Posted April 8, 2007 Share Posted April 8, 2007 When you get an error saying unexpected something, it usually means that something is there that isn't supposed to be, in this case, the " in the line that you found was not supposed to be there. 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.