Hello, first of all I checked my code on a online syntex checker, so there are no errors with the syntex. The code was based off a website (w3schools) with additions and modifications of my own. I tried changing the path of the upload folder, to a folder within the same directory of the php file, still it didn't work. I changed the file permissions of the folders, still it did not work.
Here is the part of my code that does the upload:
The PHP page is echoing this piece of code:PHP Code:function filecount($FolderPath) {
$filescount = 0;
// Open the directory
$dir = opendir($FolderPath);
// if the directory doesn't exist return 0
if (!$dir){return 0;}
// Read the directory and get the files
while (($file = readdir($dir)) !== false) {
if (is_dir($FolderPath . $file) == false) {
// Increment the File Count.
$filescount++;
}
}
// close the directory
closedir($dir);
return $filescount;
}
if (($_FILES["mp3File"]["type"] == "audio/mpeg") && ($_FILES["mp3File"]["size"] < 10485760))
{
if ($_FILES["mp3File"]["error"] > 0)
{
//header('Location: ../error_page.php?error=83343');
echo "Return Code: " . $_FILES["mp3File"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["mp3File"]["name"] . "<br />";
echo "Type: " . $_FILES["mp3File"]["type"] . "<br />";
echo "Size: " . ($_FILES["mp3File"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["mp3File"]["tmp_name"] . "<br />";
if (file_exists("../audio/" . $_POST['company'] . "commercials/" . $_FILES["mp3File"]["name"])) {
//header('Location: ../error_page.php?error=83343');
echo $_FILES["mp3File"]["name"] . " already exists. ";
}
else
{
$newFileNameCount = $filecount("../audio/" . $_POST['company'] . "commercials/") + 1;
move_uploaded_file($_FILES["mp3File"]["tmp_name"], "../audio/" . $_POST['company'] . "commercials/" . $_FILES["mp3File"]["name"]);
Then it doesn't process the code that follows..PHP Code:echo "Upload: " . $_FILES["mp3File"]["name"] . "<br />";
echo "Type: " . $_FILES["mp3File"]["type"] . "<br />";
echo "Size: " . ($_FILES["mp3File"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["mp3File"]["tmp_name"] . "<br />";
Here is the HTML that calls the code:
html Code:
<form action="p_customvoicemessage.php" method="post" enctype="multipart/form-data"> <font size="2">Browse for your mp3 file and then click Send Message.</font> <br /> <input type="file" name="mp3File" id="mp3File" /> <br /><br /> <font size="2">Expiry Date (YYYY-MM-DD):</font><br /><input type="text" name="expiryDate" value='<?php echo date("Y-m-d"); ?>' /> <br /><br/> <input type="hidden" name="company" value="<?php echo $company; ?>" /> <input type="hidden" name="username" value="<?php echo $_SESSION['username']; ?>" /> <input type="submit" value="Send Message" style="width:50%" /> </form>




Reply With Quote