I've checked many times on various websites like w3schools, php.net, i'm beginner in Php and i have a problem here. I would like to send a php uploader file on my domain folder on public_html / php. I'm not sure how to code the path of my server, like 'website.com/php/uploader' What i would need to code for the path of files uploaded, i reach my file on the web but it writes web page not accessible. To send a php file, is it a good place to put it on public_html ? I want to upload the files in a videos folder, on the server. Also there is some tricks to protect/hide the path of php files ?
Here is a big part of my code :
<!DOCTYPE html>
<html>
<head>
<h1> <title>
Multiple Uploader
</title>
</h1>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="icon" href="img…" type="image/jpg" sizes="16x16" />
<link rel="stylesheet" type="text/css" href="css/index.php.css">
</head>
<body>
<?php
if (isset($_FILES['video']) === true) {
$errors = array();
$allowed_ext = array('mp4', 'ogg', 'webm');
$file_name = $_FILES['video']['name'];
$file_ext = strtolower(end(explode('.', $file_name)));
$file_size = $_FILES['video']['size'];
$file_tmp = $_FILES['video']['tmp_name'];
if (in_array($file_ext, $allowed_ext) === false) {
$errors[] = 'Extension not allowed';
}
if ($file_size > 400000000) {
$errores[] = 'File size must be under
400MB';
}
if (empty($errors)) {
// upload file
if (move_uploaded_file($file_tmp, 'videos/'.$file_name)) {
echo 'Files ';
}
} else {
foreach ($errors as $error) {
echo $error, '<br />';
}
}
// Show content details echo '<pre>', print_r($files, true), '</pre>';
}
if (isset($_FILES['video2']) === true) {
$errors = array();
$allowed_ext = array('mp4', 'ogg', 'webm');
$file_name = $_FILES['video2']['name'];
$file_ext = strtolower(end(explode('.', $file_name)));
$file_size = $_FILES['video2']['size'];
$file_tmp = $_FILES['video2']['tmp_name'];
if (in_array($file_ext, $allowed_ext) === false) {
$errors[] = 'Extension not allowed';
}
if ($file_size > 650000000) {
$errores[] = 'File size must be under
650MB';
}
if (empty($errors)) {
// upload file
if (move_uploaded_file($file_tmp, 'videos/'.$file_name)) {
echo 'uploaded! Succeed!';
}
} else {
foreach ($errors as $error) {
echo $error, '<br />';
}
}
// Show content details echo '<pre>', print_r($files, true), '</pre>';
}
if (isset($_FILES['video3']) === true) {
$errors = array();
$allowed_ext = array('mp4', 'ogg', 'webm', 'zip');
$file_name = $_FILES['video3']['name'];
$file_ext = strtolower(end(explode('.', $file_name)));
$file_size = $_FILES['video3']['size'];
$file_tmp = $_FILES['video3']['tmp_name'];
if (in_array($file_ext, $allowed_ext) === false) {
$errors[] = 'Extension not allowed';
}
if ($file_size > 650000000) {
$errores[] = 'File size must be under
650MB';
}
if (empty($errors)) {
// upload file
if (move_uploaded_file($file_tmp, 'videos/'.$file_name)) {
echo '';
}
} else {
foreach ($errors as $error) {
echo $error, '<br />';
}
}
// Show content details echo '<pre>', print_r($files, true), '</pre>';
}
if (isset($_FILES['video4']) === true) {
$errors = array();
$allowed_ext = array('mp4', 'ogg', 'webm', 'zip');
$file_name = $_FILES['video4']['name'];
$file_ext = strtolower(end(explode('.', $file_name)));
$file_size = $_FILES['video4']['size'];
$file_tmp = $_FILES['video4']['tmp_name'];
if (in_array($file_ext, $allowed_ext) === false) {
$errors[] = 'Extension not allowed';
}
if ($file_size > 650000000) {
$errores[] = 'File size must be under
650MB';
}
if (empty($errors)) {
// upload file
if (move_uploaded_file($file_tmp, 'videos/'.$file_name)) {
echo '';
}
} else {
foreach ($errors as $error) {
echo $error, '<br />';
}
}
// Show content details echo '<pre>', print_r($files, true), '</pre>';
}
?>
<div id="content">
<form action="index.php" method="POST" enctype="multipart/form-data">
<input type="file" name="video">
<input type="file" name="video2">
<input type="file" name="video3">
<input type="file" name="video4">
<input type="submit" value="Upload">
<h3 align="left"> *zip* partes bajas </h3>
<h3 align="left"> Infos : Videos con numeros aceptados. Ejemplo : video1, video2,
video 3, etc.
<br />
Vacio = Extensions not allowed / Extensiones no apoyadas </h3>
</form>
</div>
</body>
thats your current path.
if you want to hide the files on the server, put them in a directory that is further up the tree than the public_html/ directory, perhaps in their own videos/ directory
etc..