Monday, January 31, 2022

ArchTitus Linux

 https://github.com/ChrisTitusTech/ArchTitus



Windows 10 & 11 Sound Keyboard Application free download




https://michael.wright.uk/php-file-uploads/


<?php


// Check for errors

if($_FILES['file_upload']['error'] > 0){

    die('An error ocurred when uploading.');

}


if(!getimagesize($_FILES['file_upload']['tmp_name'])){

    die('Please ensure you are uploading an image.');

}


// Check filetype

if($_FILES['file_upload']['type'] != 'image/png'){

    die('Unsupported filetype uploaded.');

}


// Check filesize

if($_FILES['file_upload']['size'] > 500000){

    die('File uploaded exceeds maximum upload size.');

}


// Check if the file exists

if(file_exists('upload/' . $_FILES['file_upload']['name'])){

    die('File with that name already exists.');

}


// Upload file

if(!move_uploaded_file($_FILES['file_upload']['tmp_name'], 'upload/' . $_FILES['file_upload']['name'])){

    die('Error uploading file - check destination is writeable.');

}


die('File uploaded successfully.');


//---------------------


//https://www.plus2net.com/php_tutorial/php_file_upload.php




<form action='uploadck.php' method=post  enctype='multipart/form-data' >

Upload this file: <input type=file name='file_up'>

<input type=submit value='Upload Image'></FORM>


<?Php

echo "Maximum allowed file size: ".ini_get('upload_max_filesize');

echo "<br>";

echo "Maximum input time : ".ini_get('max_input_time');

echo "<br>";

echo "Maximum execution time : ".ini_get('max_execution_time');

echo "<br>";

echo "Maximum Post size : ".ini_get('post_max_size');

?>


<?Php

$file_upload_flag="true"; // Flag to check conditions

$file_up_size=$_FILES['file_up'][size];


echo "File Name:".$_FILES[file_up][name];

echo "<br>File Size:".$_FILES[file_up][size];

echo "<br>File Type:".$_FILES[file_up][type];

echo "<br>File tmp_name:".$_FILES[file_up][tmp_name];

echo "<br>File error:".$_FILES[file_up][error];

echo "<br>---End of uploaded file details---<br><br>";


if ($_FILES[file_up][size]>250000){

$msg=$msg."Your uploaded file size is more than 250KB ";

$msg.=" so please reduce the file size and then upload.<BR>";

$file_upload_flag="false";

}


// allow only jpeg or gif files, remove this if not required //

if (!($_FILES[file_up][type] =="image/jpeg" OR $_FILES[file_up][type] =="image/gif"))

{$msg=$msg."Your uploaded file must be of JPG or GIF. ";

$msg.="Other file types are not allowed<BR>";

$file_upload_flag="false";}


$file_name=$_FILES[file_up][name];

// the path with the file name where the file will be stored

$add="upload/$file_name"; 


if($file_upload_flag=="true"){ // checking the Flag value 


if(move_uploaded_file ($_FILES[file_up][tmp_name], $add)){

// do your coding here to give a thanks message or any other thing.

$msg="File successfully uploaded";

}else{

echo "Failed to upload file Contact Site admin to fix the problem";

}

}else{

$msg .= " Failed to upload file ";

}

echo " $msg <br><br> <a href=upload.php>Return to File upload </a>";

?>

//--------------------


<?php
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));

// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
  $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
  if($check !== false) {
    echo "File is an image - " . $check["mime"] . ".";
    $uploadOk = 1;
  } else {
    echo "File is not an image.";
    $uploadOk = 0;
  }
}

// Check if file already exists
if (file_exists($target_file)) {
  echo "Sorry, file already exists.";
  $uploadOk = 0;
}

// Check file size
if ($_FILES["fileToUpload"]["size"] > 500000) {
  echo "Sorry, your file is too large.";
  $uploadOk = 0;
}

// Allow certain file formats
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif" ) {
  echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
  $uploadOk = 0;
}

// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
  echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
else {
  if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
    echo "The file ". htmlspecialchars( basename( $_FILES["fileToUpload"]["name"])). " has been uploaded.";
  } else {
    echo "Sorry, there was an error uploading your file.";
  }
}
?>


No comments:

Post a Comment

Beogradsko programiranje=