0% found this document useful (0 votes)
2 views

doctype html

The document consists of an HTML form for file uploads and a PHP script to handle the uploaded files. It allows users to upload files with specific extensions (jpg, jpeg, png, pdf) and checks for errors, file size, and type before moving the file to a designated folder. If successful, it redirects to 'index.php' with a success message, otherwise, it displays relevant error messages.

Uploaded by

hawariya abel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

doctype html

The document consists of an HTML form for file uploads and a PHP script to handle the uploaded files. It allows users to upload files with specific extensions (jpg, jpeg, png, pdf) and checks for errors, file size, and type before moving the file to a designated folder. If successful, it redirects to 'index.php' with a success message, otherwise, it displays relevant error messages.

Uploaded by

hawariya abel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

1.<!

doctype html>

<html>

<head>

<title></title>

</head>

<body>

<form action="upload.php"method='POST'enctype="multipart/form-data">

<input type="file" name="file">

<button type="submit"name="submit">UPLOAD</button>

</form>

</body>

</html>

2. <?php

if(isset($_post['submit'])){

$file=$_files['file'];

print_r($file);

$fileName=$_files['file']['name'];

$fileTmpname=$_files['file']['tmp_name'];

$fileSize=$_files['file']['size'];

$fileError=$_files['file']['error'];

$fileType=$_files['file']['type'];

$fileExt=explode('.',$fileName);

$fileActualExt=strtolower(end($fileExt));

$allowed=array('jpg','jpeg','png','pdf');
if(in_array($fileActualExt,$allowed)){

if($fileError===0) {

if($fileSize<1000000){

$fileNameNew=uniqid('',true).".".$fileActualExt;

$fileDestination='uploads/'.$fileNameNew;

move_uploaded_file($fileTmpname,$fileDestination);

header("location:index.php?uploadsuccess");

}else{

echo"your file is too big";

}else{

echo"there was an error uploading your file";

}else{

echo"you can not upload files of this type!";

You might also like