corillo181 Posted December 6, 2006 Share Posted December 6, 2006 i got a code to upload picture i triad it to upload music but is not wokring is there a special way or music than picture?this is the code.[code]<?php$dir='../music/hmp/';$filesize = $_FILES['sfile']['size'];$filetype = $_FILES['sfile']['type'];$filename = $_FILES['sfile']['name'];$pos = strrpos($filename, '.');$newname = $song . substr($filename, $pos);$filepath = $dir . $newname;$result=copy($tmpname, $filepath);if(!$result){ echo " a problem occur";}?>[/code] Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted December 6, 2006 Share Posted December 6, 2006 check your coding, $tmpname isnt a variable. you havent given it any value. Quote Link to comment Share on other sites More sharing options...
corillo181 Posted December 6, 2006 Author Share Posted December 6, 2006 well i dont trust my eyes any longer so it still not wokring is it something i dont see?[code]<?phpinclude_once'../includes/db.php';//get variable$dir='../music/hmp/';$filesize = $_FILES['sfile']['size'];$filetype = $_FILES['sfile']['type'];$filename = $_FILES['sfile']['name'];$tmpname = $_FILES['sfile']['tmp_name'];$pos = strrpos($filename, '.');$newname = $song . substr($filename, $pos);$filepath = $dir . $newname;$result=copy($tmpname, $filepath);if(!$result){ echo " a problem occur";}?>[/code] Quote Link to comment Share on other sites More sharing options...
corillo181 Posted December 6, 2006 Author Share Posted December 6, 2006 nothing? Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted December 6, 2006 Share Posted December 6, 2006 are you using:[b]enctype="multipart/form-data"[/b]in your form tag? Quote Link to comment Share on other sites More sharing options...
corillo181 Posted December 6, 2006 Author Share Posted December 6, 2006 yeah i amthe problme is in the code right there. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted December 6, 2006 Share Posted December 6, 2006 is "[b]sfile[/b]" the correct name attribute from the form? Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted December 6, 2006 Share Posted December 6, 2006 and where is $song variable defined? Quote Link to comment Share on other sites More sharing options...
corillo181 Posted December 6, 2006 Author Share Posted December 6, 2006 yes it is..like i said.. this code i took it from one of my already working codes.. i have it as a gallery in a website..i just never used it to upload music..i was trying to see if it works with music but is not working.[code]<form action="../phpscripts/muls.php" method="post" enctype="multipart/form-data" name="ulmusic" id="ulmusic"> <table border="0"> <tr> <td>song_name</td> <td><label> <input name="song" type="text" id="song" /> </label></td> </tr> <tr> <td><label>song:</label></td> <td><input name="ulfile" type="file" id="ulfile" /></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="UpLoad" /></td> </tr> </table></form>[/code][code]<?phpinclude_once'../includes/db.php';//get variable$dir='../music/hmp/';$filesize = $_FILES['sfile']['size'];$filetype = $_FILES['sfile']['type'];$filename = $_FILES['sfile']['name'];$tmpname = $_FILES['sfile']['tmp_name'];$pos = strrpos($filename, '.');$newname = $song . substr($filename, $pos);$filepath = $dir . $newname;$result=copy($tmpname, $filepath);if(!$result){ echo " a problem occur";}?>[/code] Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted December 6, 2006 Share Posted December 6, 2006 No its not...[code]<?phpinclude_once'../includes/db.php';//get variable$dir='../music/hmp/';$filesize = $_FILES['ulfile']['size'];$filetype = $_FILES['ulfile']['type'];$filename = $_FILES['ulfile']['name'];$tmpname = $_FILES['ulfile']['tmp_name'];$pos = strrpos($filename, '.');$newname = $song . substr($filename, $pos);$filepath = $dir . $newname;$result=copy($tmpname, $filepath);if(!$result){ echo " a problem occur";}?>[/code] Quote Link to comment Share on other sites More sharing options...
corillo181 Posted December 6, 2006 Author Share Posted December 6, 2006 nah i gave you the wrong code it still the same [code]<form action="../phpscripts/muls.php" method="post" enctype="multipart/form-data" name="ulmusic" id="ulmusic"> <table border="0"> <tr> <td>song_name</td> <td><label> <input name="song" type="text" id="song" /> </label></td> </tr> <tr> <td><label>song:</label></td> <td><input name="sfile" type="file" id="ulfile" /></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="UpLoad" /></td> </tr> </table></form>[/code][code]<?phpinclude_once'../includes/db.php';//get variable$song=$_POST['song'];$dir='../music/hmp/';$filesize = $_FILES['sfile']['size'];$filetype = $_FILES['sfile']['type'];$filename = $_FILES['sfile']['name'];$tmpname = $_FILES['sfile']['tmp_name'];$pos = strrpos($filename, '.');$newname = $song . substr($filename, $pos);$filepath = $dir . $newname;$result=copy($tmpname, $filepath);if(!$result){ echo " a problem occur";}?>[/code] Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted December 6, 2006 Share Posted December 6, 2006 hmmm... just querying, but shouldnt [code=php:0]$result=copy($tmpname, $filepath);[/code] be [code=php:0]$result = copy($filename, $filepath);[/code]and why not try move_uploaded_file(), see if that makes a difference. Quote Link to comment Share on other sites More sharing options...
corillo181 Posted December 6, 2006 Author Share Posted December 6, 2006 tried that already.. i still get the not uploaded result.man i tried anytihng it wokrs with picture but not with music why is that ? Quote Link to comment Share on other sites More sharing options...
noobstar Posted December 6, 2006 Share Posted December 6, 2006 Hi there,Here is a brilliant file upload script i used for my tafe project, i tested it and it can upload just about any file format you just need to get rid of the file format restrictions up topHere is the link: [url=http://www.w3schools.com/php/php_file_upload.asp]http://www.w3schools.com/php/php_file_upload.asp[/url] Quote Link to comment Share on other sites More sharing options...
corillo181 Posted December 6, 2006 Author Share Posted December 6, 2006 sorry everyone for the problme it was just the directory i had a llowercase but the directory is with a uppercase Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted December 7, 2006 Share Posted December 7, 2006 omg! lol. such a silly mistake, make sure you check those!! 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.