Virtualhost Port Production and Development

file "/etc/httpd/conf/httpd.conf"

--------------------------
Listen 8001 #Development
Listen 8002 #Production
--------------------------

file "/etc/httpd/conf/vhosts/devel.me"
---------------------------------------------------------------------
<VirtualHost devel.me:8001>
ServerAdmin sendhi@devel.me
DocumentRoot "/home/sendhi/http/devel.me/dev"
ServerName devel.me
ServerAlias devel.me
ErrorLog "/var/log/httpd/devel.me-error_log"
CustomLog "/var/log/httpd/devel.me-access_log" common

<Directory "/home/sendhi/http/devel.me/dev">
Require all granted
AllowOverride All
</Directory>
</VirtualHost>

<VirtualHost devel.me:8002>
ServerAdmin sendhi@devel.me
DocumentRoot "/home/sendhi/http/devel.me/prod"
ServerName devel.me
ServerAlias devel.me
ErrorLog "/var/log/httpd/devel.me-error_log"
CustomLog "/var/log/httpd/devel.me-access_log" common

<Directory "/home/sendhi/http/devel.me/prod">
Require all granted
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/srv/http"
ServerName localhost
# ServerAlias localhost
</VirtualHost>

—————————————————————-

Advertisements

is_dir direktori – subdirektori – file upload PHP

Pertama buat dulu index.php seperti dibawah ini

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form action="dir.php" method="post" enctype="multipart/form-data">
Direktori<input type="text" name="dir"><br />
Subdirektori<input type="text" name="subdir"><br />
Pilih File: <input name="userfile" type="file" /><br />
<input type="submit" name="submit" value="Run Program">
</form>
</body>
</html>

 

Isi File dir.php

 

<?php

if (isset($_POST['submit'])) {
// Direktori
$dir = $_POST['dir'];

// Subdirektori
$subdir = $_POST['subdir'];
$DirSub = "$dir/$subdir/";

// Deskripsi Gambar
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['filetype']['type'];
$uploadfile = $DirSub . $fileName;

// if Direktori Pertama
if (is_dir($dir)) {
echo "Direktori {$dir} Sudah Ada <br />";
} else {
mkdir($dir , 0777, true);
echo "Direktori {$dir} Baru Saja di Buat <br />";
}

// if Subdirektori
if (is_dir($DirSub)) {
echo "Direktori {$subdir} Sudah Ada <br />";
} else {
mkdir($DirSub , 0777, true);
echo "SubDirektori {$subdir} Baru Saja di Buat <br />";
}

if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File Berhasil di Upload: $DirSub$fileName";
} else {
echo "File gagal di upload";
}

}