<html>
<head>
<title>PHP microsoft docx file Upload script</title>
</head>
<body>
<div><?php
if ( isset( $_FILES['docFile'] ) ) {
if ($_FILES['docFile']['type'] == "application/vnd.openxmlformats-officedocument.wordprocessingml.document") {
$source_file = $_FILES['docFile']['tmp_name'];
$dest_file = "upload/".$_FILES['docFile']['name'];
if (file_exists($dest_file)) {
print "The file name already exists!!";
}
else {
move_uploaded_file( $source_file, $dest_file )
or die ("Error!!");
if($_FILES['docFile']['error'] == 0) {
print "File was successfully uploaded!! <br/><br/>";
print "<b><u>Details : </u></b><br/>";
print "File Name : ".$_FILES['docFile']['name']."<br.>"."<br/>";
print "File Size : ".$_FILES['docFile']['size']." bytes"."<br/>";
print "File location : upload/".$_FILES['docFile']['name']."<br/>";
}
}
}
else {
if ( $_FILES['docFile']['type'] != "application/vnd.openxmlformats-officedocument.wordprocessingml.document") {
print "Error occured while uploading file : ".$_FILES['docFile']['name']."<br/>";
print "Invalid file extension, should be docx !!"."<br/>";
print "Error Code : ".$_FILES['docFile']['error']."<br/>";
}
}
}
?></div>
<form enctype="multipart/form-data"
action="<?php print $_SERVER['PHP_SELF']?>" method="post">
<p><input type="hidden" name="MAX_FILE_SIZE" value="1000000" /> <input
type="file" name="docFile" /><br />
<input type="submit" value="upload!" /></p>
</form>
</body>
</html>
More Posts related to PHP,
- Delete file using PHP code : unlink()
- PHP header location function not called
- 403 forbidden error for Image
- Call PHP function on Button click using jquery ajax
- How to Pretty Print JSON in PHP
- Step-by-Step Guide: How to Fix - Error Establishing a Database Connection in WordPress
- PHP Base64 encoding decoding a variable
- PHP Fatal error : Call to a member function bind_param() on a non-object
- PHP.ini: How to Remove URL Forward Slash Before Single or Double Quotes
- PHP drag and drop file upload tutorial using dropzone.js
- Upload Pdf file using PHP Script
- PHP Warning: Cannot modify header information - headers already sent
- macOS - cannot calculate MAC address: Using fd 9 hv_vm_create HV_ERROR [PHP XAMPP]
- PHP Code for sending Emails
- How to destroy PHP session()
- Installing vue.js in Laravel 8
- PHP 301 Redirect Permanently
- Upload docx file using PHP script
- Save current timestamp in MySQL using PHP mysqi binding
- Copy file from one directory to other in Php
- Failed to load resource: net::ERR_CACHE_MISS PHP
- PHP Script to Upload Images to Server
More Posts:
- How to integrate Salesforce CRM Sales and Service with Microsoft Teams - Teams
- Check if a Java Date String is Valid or Not (Java 8) - Java
- Python Program: Use NumPy to generate a random number between 0 and 1 - Python-Programs
- [Fix] Java Exception with Lambda - Cannot invoke because object is null - Java
- Android appcompat_v7 Error retrieving parent for item: No resource found that matches the given name - Android
- How to Escape a character in a Bash command String - Bash
- Ways to Initialize HashMap Collection in Java - Java
- Is Java 20 an LTS Version? - Java