fejl eller hva
hej,jeg har en php code til at uploade med via ftp men den virker ikke og kan IKKE finde fejlen. er der nogen derude der kan?!
------------------------------------------
<?php
$location = "/music/temp-upload";
$maxfilesize = 1500000;
$error = "";
$filetypes = array("application/vnd.rn-realmedia",
"audio/x-pn-realaudio",
"audio/x-realaudio");
if(isset($_POST['submitupload']))
{
if (isset($HTTP_POST_FILES['file']['name']) && $HTTP_POST_FILES['file']['name'] == "")
{
$error = "<font color=red><b>$filenoneselected</b></font>";
}
else
{
//a file was uploaded do something
if ($HTTP_POST_FILES['file']['size'] > $maxfilesize)
{
$error = "<font color=red><b>$filesizeerror 1,5 mb.</b></font>";
unlink($HTTP_POST_FILES['file']['tmp_name']);
}
elseif(!in_array($HTTP_POST_FILES['file']['type'],$filetypes))
{
//the file is under the specified number of bytes do something
print $error = "<font color=red><b>$filetypeerror</b></font>";
unlink($HTTP_POST_FILES['file']['tmp_name']);
}
else
{
//the file is the correct format do upload
$songname = $_POST['songname'];
$singername = $_POST['singername'];
$thefile = $_POST['thefile'];
$tempfile = $HTTP_POST_FILES['file']['name'];
$temp = explode('.', $tempfile);
$file = $temp[0];
$ext = "rm";
$filename = strtolower($file."-".$songname.".".$ext);
$filename = str_replace(' ', '', $filename);
// set up basic connection
$ftp_server = "ftp.server.dk";
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, "server.dk", "****");
ftp_chdir($conn_id, $location);
//SET FTP TO PASSIVE MODE
ftp_pasv($conn_id,FALSE);
if(ftp_put($conn_id, $HTTP_POST_FILES['file']['name'], $filename, FTP_BINARY))
{
$filetype = $HTTP_POST_FILES['file']['type'];
$fileloc = $HTTP_POST_FILES['file']['name'];
}
else
{
$error = "Error! Sorry an error has occured while uploading.. ";
}
}
}//if upload not submitted
else
{
echo '<tr>
<td width="100%" colspan="2"><font color=#336699 size=3><b>'; print $musicuploadit; echo'</font><br><hr></td></tr>
<tr>
<form action="" method="POST" enctype="multipart/form-data">';
print $error;
echo '<td width="66%"><font size="2" color="#336699"><b>'; print $musicsongname; echo'</b></font></td>
<td width="63%"><input class=wideinput type="text" size="20" name="songname"></td>
</tr>
<tr>
<td width="66%"><font size="2" color="#336699"><b>'; print $musicsingername; echo'</b></font></td>
<td width="63%"><input class=wideinput type="text" size="20" name="singername"><br>
</td>
</tr>
<tr>
<td width="66%"><font size="2" color="#336699"><b>'; print $musicchoosefile; echo '</b></font></td>
<td width="63%"><input class=wideinput type="file" name="file" onchange="thefile.value=file.value">
<input type="hidden" name="thefile" value"">
</td>
</tr>
<td width="100%" colspan="2"><hr></td></tr>
<tr>
<td>
<input class=widebutton type="submit" name="submitupload" value=" Upload ">
</td>
</form>
</tr>';
}
?>
