I am working on Gift voucher plugin where if a customer wants to gift his/her friend. Hence, some may need to send pdf files( this is not the mandatory field, but if someone needs it. ) So following is my uploading code:[ I am going to upload files in pdf/ folder ]
// pdf file
echo $pdf_file = $_POST['hidden_pdf_file'] . "<br>";
echo $pdf_file_name = $_POST['hidden_pdf_name'] . "<br>";
echo $path=plugin_dir_url( __FILE__ )."pdf/";
// Use the WordPress API to upload the file
require_once( ABSPATH . 'wp-admin/includes/file.php' );
$uploadedfile = $pdf_file_name;
$upload_overrides = array( 'test_form' => false );
$movefile = wp_handle_upload( $uploadedfile, $upload_overrides );
if ( $movefile ) {
echo "File is valid, and was successfully uploaded.\n";
var_dump( $movefile);
} else {
echo "Possible file upload attack!\n";
}
// end pdf upload
ERROR MESSAGE
http://test.giitcomputer.com/wp-content/plugins/simple-gift-cards/pdf/
File is valid and was successfully uploaded.But There is no file in the "pdf/" directory.
NOTE: IT SHOWS FILE UPLOADED SUCCESSFULLY.BUT, SEE SECOND ERROR....
array(1) { ["error"]=> string(212) "File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini." }