<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,
- PHP Code for sending Emails
- PHP drag and drop file upload tutorial using dropzone.js
- Delete file using PHP code : unlink()
- Save current timestamp in MySQL using PHP mysqi binding
- Failed to load resource: net::ERR_CACHE_MISS PHP
- PHP Warning: Cannot modify header information - headers already sent
- PHP header location function not called
- How to destroy PHP session()
- Upload docx file using PHP script
- Call PHP function on Button click using jquery ajax
- Upload Pdf file using PHP Script
- 403 forbidden error for Image
- PHP Base64 encoding decoding a variable
- PHP 301 Redirect Permanently
- Copy file from one directory to other in Php
- PHP Script to Upload Images to Server
- Installing vue.js in Laravel 8
- 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
- macOS - cannot calculate MAC address: Using fd 9 hv_vm_create HV_ERROR [PHP XAMPP]
More Posts:
- [fix] RabbitMQ: AuthenticationFailureException ACCESS_REFUSED Login refused authentication mechanism PLAIN - 2022
- Install the minimal Linux on Docker (only 5 mb Alpine Linux) - Docker
- Add Sketch from iPhone to MacBook with macOS Monterey - MacOS
- Word count in Notepad++ - NotepadPlusPlus
- How to hide toolbar on Notepad++ - NotepadPlusPlus
- ModuleNotFoundError: No module named qdarkstyle.colorsystem [Python] - Python
- Fix: Notepad++ bottom status bar not visible - NotepadPlusPlus
- [Solved] Mic not working on iPhone 7 after iOS 14 upgrade - Apple