Jump to content

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/197696-need-a-little-help-please/
Share on other sites

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 .

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.