Error de carga de archivo PHP
<?php
// files specified
$file_name = $_FILES ['upload']['name'];
$file_size = $_FILES ['upload']['size'];
$file_tmp = $_FILES ['upload']['tmp_name'];
// the folder or default directory of uploaded files
$target_dir = "uploads/$file_name";
// Assigned variables to the http Post method
$submit = $_POST['submit'];
// ASSIGN variables to the FILES super variable;
$files = $_FILES['upload']['name'];
// Assigned variables to the supported files type
$file_types = array('png','ptt','php','mp4','jpg','jpeg','txt','zip','pdf');
// specify where the supported extensions will start from
$file_ext = explode('.', $file_name);
$file_ext = strtolower(end($file_ext));
// Upload script starts here
if (isset($submit)) {
if (!empty($files)) {
if (in_array($file_ext,$file_types)) {
if ($file_size <= 1200000) {
// 1200000 = 1.2mb
move_uploaded_file($file_tmp,$target_dir);
echo '<p style="color: green">Upload Successful !</p>';
} else {
echo '<p style="color: red">File size too large !</p>';
}
}else {
echo '<p style="color: red"> Invalid file format!</p>';
}
}else {
echo '<p style="color: red">file not selected!!</p>';
}
}
Omo Junior