Never mind, it is PHP.
This script lets me upload files via HTTP, I want to make it more secure by putting it in its own password protected folder. So, I need it to save the files one level up and then two levels down in a folder called listed. (ie ../downloads/listed) it is currently in downloads. It is going to be in its own separate folder off of the root as is the downloads folder. Also, How would I change it so that it makes the links have the subdomian of files instead of uploads which will be in.
<?php
$site_name = $_SERVER['HTTP_HOST'];
$url_dir = "http://".$_SERVER['HTTP_HOST'
$url_this = "http://".$_SERVER['HTTP_HOST'
$upload_dir = "Listed/";
$upload_url = $url_dir."/Listed/";
$message ="";
//create upload_files directory if not exist
//If it does not work, create on your own and change permission.
if (!is_dir("Listed")) {
die ("upload_files directory doesn't exist");
}
if ($_FILES['userfile']) {
$message = do_upload($upload_dir, $upload_url);
}
else {
$message = "";
}
print $message;
function do_upload($upload_dir, $upload_url) {
$temp_name = $_FILES['userfile']['tmp_name'];
$file_name = $_FILES['userfile']['name'];
$file_type = $_FILES['userfile']['type'];
$file_size = $_FILES['userfile']['size'];
$result = $_FILES['userfile']['error'];
$file_url = $upload_url.$file_name;
$file_path = $upload_dir.$file_name;
//File Name Check
if ( $file_name =="") {
$message = "Invalid File Name Specified";
return $message;
}
//File Size Check
else if ( $file_size > 5000000) {
$message = "The file size is over 5MB.";
return $message;
}
//File Type Check
else if ( $file_type == "text/plain" ) {
$message = "Sorry, You cannot upload any script file" ;
return $message;
}
$result = move_uploaded_file($temp_name, $file_path);
$message = ($result)?"File url <a href=$file_url>$file_url</a>" :
"Somthing is wrong with uploading a file.";
return $message;
}
?>
<form name="upload" id="upload" ENCTYPE="multipart/form-data" method="post">
Upload File:<input type="file" id="userfile" name="userfile">
<input type="submit" name="upload" value="Upload">
</form>
This script lets me upload files via HTTP, I want to make it more secure by putting it in its own password protected folder. So, I need it to save the files one level up and then two levels down in a folder called listed. (ie ../downloads/listed) it is currently in downloads. It is going to be in its own separate folder off of the root as is the downloads folder. Also, How would I change it so that it makes the links have the subdomian of files instead of uploads which will be in.
<?php
$site_name = $_SERVER['HTTP_HOST'];
$url_dir = "http://".$_SERVER['HTTP_HOST'
$url_this = "http://".$_SERVER['HTTP_HOST'
$upload_dir = "Listed/";
$upload_url = $url_dir."/Listed/";
$message ="";
//create upload_files directory if not exist
//If it does not work, create on your own and change permission.
if (!is_dir("Listed")) {
die ("upload_files directory doesn't exist");
}
if ($_FILES['userfile']) {
$message = do_upload($upload_dir, $upload_url);
}
else {
$message = "";
}
print $message;
function do_upload($upload_dir, $upload_url) {
$temp_name = $_FILES['userfile']['tmp_name'];
$file_name = $_FILES['userfile']['name'];
$file_type = $_FILES['userfile']['type'];
$file_size = $_FILES['userfile']['size'];
$result = $_FILES['userfile']['error'];
$file_url = $upload_url.$file_name;
$file_path = $upload_dir.$file_name;
//File Name Check
if ( $file_name =="") {
$message = "Invalid File Name Specified";
return $message;
}
//File Size Check
else if ( $file_size > 5000000) {
$message = "The file size is over 5MB.";
return $message;
}
//File Type Check
else if ( $file_type == "text/plain" ) {
$message = "Sorry, You cannot upload any script file" ;
return $message;
}
$result = move_uploaded_file($temp_name, $file_path);
$message = ($result)?"File url <a href=$file_url>$file_url</a>" :
"Somthing is wrong with uploading a file.";
return $message;
}
?>
<form name="upload" id="upload" ENCTYPE="multipart/form-data" method="post">
Upload File:<input type="file" id="userfile" name="userfile">
<input type="submit" name="upload" value="Upload">
</form>