<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 increase macOS Terminal text font size (Big Sur) - MacOS
- PowerShell Traditional For Loop Example - Powershell
- Make Notepad++ the default App for .txt file extensions - NotepadPlusPlus
- How to Check PowerShell Version? [Windows/Mac/Linux] - Powershell
- 18: Get Sub List By Slicing a Python List - 1000+ Python Programs - Python-Programs
- How to Sort a LinkedList in Java - Java
- How to know the Serial Number of MacBook on macOS Ventura 13.0 - MacOS
- SharePoint 2016 error - Could not find file ManageUserProfileServiceApplicationTenantSimplified.xml - SharePoint