taichimasta Posted April 6, 2010 Share Posted April 6, 2010 I'm not here for a "How to" just need a bit of help to figure out "Why it isn't working" I know my code is correct and name all variables and will build more once i get to simple work. First i had it kinda work it uploaded a file but the name was the name of the folder so instead of example: $path = "/music"; // the folder in the same directory (yea i learned quick where it goes) $path = $path.basename($filename); // file name example.jpg or something instead i got the output music <-- yea no extension and after i tried to figure out what i did wrong it stop working completely but it successfully uploaded the file and everything.. /////////////////////////////////////////////////////////////////////////////////////////// //file variables put in another file so it can be sperate //path to the folder where the data will be sent $filepath = "\music"; //// file path and basename example.wmv so its (uploaded_music/example.wmv) $filepath = $filepath . basename($filename); /// file size and type $readsize = $_FILES["upload"]["size"]; $readtype = $_FILES["upload"]["type"]; // name of the data being uploaded $filename = $_FILES["upload"]["name"]; $filetemp = $_FILES["upload"]["tmp_name"]; /// the uploader itself and the checker $uploaderLine = move_uploaded_file($filetemp , $filepath); ?> <div class="video"> <?php if($uploaderLine == true) { echo "The File: <b>".basename($filename)."</b> has been uploaded successfully. \n <br/>"; echo "The size is: <b>".calculatebytes($readsize)."</b> and the limit is 50MB."; echo "<br/>".ceil($readsize/100); //display image if not an image don't display it echo "<br/> <img src=\"\music\\".basename($filename)."\" border=\"0\">"; } else { echo "Sorry something went wrong with the file: <b>".basename($filename)."</b> , please try again.<br/>Errors Number: <b>".$_FILES["upload"]["error"]."</b>"; echo "<br/>The size is: <b>".$readsize."</b> and the limit is 50MB. <br/>"; echo $readsize." - File Size<br/>"; echo "52428800 - Limit \n <br/>"; } ?> /////////////////////////////////////////////////////////////////////////////////////////// <br/> <form method="POST" enctype="multipart/form-data"> item uploader: <input type="file" name="upload"> <input type="hidden" name="MAX_FILE_SIZE" value="52428800"> <input type="submit" name ="fileupload" value="Upload"><br/> </form> </div> Quote Link to comment https://forums.phpfreaks.com/topic/197696-need-a-little-help-please/ Share on other sites More sharing options...
DavidAM Posted April 6, 2010 Share Posted April 6, 2010 unless there is more code that you did not show, you are trying to use the $filename before you assign the value to it. move those $filepath assignments down below the $filename assignment and you should be good to go. Quote Link to comment https://forums.phpfreaks.com/topic/197696-need-a-little-help-please/#findComment-1037509 Share on other sites More sharing options...
taichimasta Posted April 6, 2010 Author Share Posted April 6, 2010 i fixed it , i thought i corrected that but whatever , it still says its uploaded successfully but nothing. here is what it looks like now. //file variables put in another file so it can be sperate //path to the folder where the data will be sent $filepath = "\music"; /// file size and type $readsize = $_FILES["upload"]["size"]; $readtype = $_FILES["upload"]["type"]; // name of the data being uploaded $filename = $_FILES["upload"]["name"]; $filetemp = $_FILES["upload"]["tmp_name"]; //// file path and basename example.wmv so its (uploaded_music/example.wmv) $filepath = $filepath.basename($filename); /// the uploader itself and the checker $uploaderLine = move_uploaded_file($filetemp,$filepath); ?> <div class="video"> <?php if($uploaderLine == true) { echo "The File: <b>".basename($filename)."</b> has been uploaded successfully. \n <br/>"; echo "The size is: <b>".calculatebytes($readsize)."</b> and the limit is 50MB."; echo "<br/>".ceil($readsize/100); //display image if not an image don't display it ?> <br/> <img src="<?php echo "music/".$filename; ?>" border="0"/> <?php } else { echo "Sorry something went wrong with the file: <b>".basename($filename)."</b> , please try again.<br/>Errors Number: <b>".$_FILES["upload"]["error"]."</b>"; echo "<br/>The size is: <b>".$readsize."</b> and the limit is 50MB. <br/>"; echo $readsize." - File Size<br/>"; echo "52428800 - Limit \n <br/>"; } ?> <br/> <form method="POST" enctype="multipart/form-data"> item uploader: <input type="file" name="upload"> <input type="hidden" name="MAX_FILE_SIZE" value="52428800"> <input type="submit" name ="fileupload" value="Upload"><br/> </form> </div> oh and by the way , i can't find the edit button where that bloody thing go? i don't want to repost the whole code and everything constantly, rather then just edit the post . Quote Link to comment https://forums.phpfreaks.com/topic/197696-need-a-little-help-please/#findComment-1037523 Share on other sites More sharing options...
taichimasta Posted April 6, 2010 Author Share Posted April 6, 2010 fixed it it was the path that was the problem. Thank you for your reply(s) Quote Link to comment https://forums.phpfreaks.com/topic/197696-need-a-little-help-please/#findComment-1037527 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.