I tried But i cant get it fixed
This is my code
<form enctype="multipart/form-data" id="patientEnquiry" method="post" class="form" action="" >
<div class="form-group">
<input type="text" name="subject" id="subject" required="required" maxlength="100" class="form-
control">
</div>
<input type="file" id="passport" name="passport" class="required">
</form>
<button class="request" id="patientsub" >submit</button>
and This is what i placed in functions.php
$target_dir = get_home_path().'wp-content/uploads/';
$file = $_FILES['passport']['name'];
$path = pathinfo($file);
$filename = $path['filename'];
$ext = $path['extension'];
$temp_name = $_FILES['passport']['tmp_name'];
$path_filename_ext = $target_dir.$filename.".".$ext;
// Check if file already exists
if (file_exists($path_filename_ext)) {
echo "Sorry, file already exists.";
}else{
move_uploaded_file($temp_name,$path_filename_ext);
echo "Congratulations! File Uploaded Successfully.";
}
when i try to echo $file; i'm not getting anything please help me
Maybe problem is getting path you need to use ABSOLUTE path.
$target_dir = str_replace('\\', '/', ABSPATH)."wp-content/uploads/";
Related
I'm trying to add integration with Opayo payment on website.
The form
I just have this code:
I change card and card holder details for security reason
$text ='Description=Finishing transaction&Currency=GBP&VendorTxCode=22013115512924219800&amount=5.00&BillingSurname=Paul&BillingFirstnames=Smith&BillingAddress1=ddd&BillingCity=London&BillingPostCode=BH99PU&BillingCountry=GB&DeliveryState=&DeliverySurname=Jhon&DeliveryFirstnames=Jhon&DeliveryAddress1=ddd&DeliveryCity=London&DeliveryPostCode=BH99PU&BillingState=&DeliveryCountry=GB&VendorData=Testing Data &ApplyAVSCV2=2&referid=&language=&website=&Phone=SendEmail=&CardHolder=Smith Alves Gomety&Cardnumber=5434391244446116&ExpiryDate=1229&CardType=MC';
$key = "yuG4B75PE2Gaqgus";
$iv = hex2bin('00000000000000000000000000000000');
$ciphertext_raw = openssl_encrypt($text , "AES-128-CBC", $key , OPENSSL_RAW_DATA, $iv);
$hex = bin2hex($ciphertext_raw);
$hex ='#' . $hex;
<form method="POST" id="SagePayForm" action="https://test.sagepay.com/gateway/service/vspform-register.vsp">
<input type="hidden" name="VPSProtocol" value= "4.00">
<input type="hidden" name="TxType" value= "PAYMENT">
<input type="hidden" name="Vendor" value= "xxxxxxxxxxxxxxx">
<input type="hidden" name="Crypt" value= "<?php echo $hex; ?>">
<input type="submit" value="continue to SagePay">
</form>
The page comes like following
Page generated
And, when I click on "Continue to SagePay" I'm receiving the following
Ssubmiting result
Does anyone can help me with this?
How to integrate in my own form or on SagePay?
Does anyone has full PHP code to this integration including returnings codes,,,,
I am working on a project using symfony.I want to use Sonata Media bundle,in order to upload image.
Unfortunately I don't knwo how to use it or how to start.
I havethis form :
<form action="" method="POST" class="filePhotoForm form-inline" role="form">
<div class="form-group">
<input type="button" class="btn btn-start-order browse" value="Browse">
<input type="text" class="form-control file-name" readonly="readonly" placeholder="No file selected">
<input type="file" name="filePhoto" id="filePhoto" class="hidden file-upload">
</div><br/><br/>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
And the code in controller:
public function changePictureAction(Request $request)
{
return $this->render('MedAppBundle:Profile:change_picture.html.twig');
}
Can you help with the basics of uploading?
Thank you!
i have made a custom function for that
protected function saveImageMediaBundle($file,$context = 'default')
{
$mediaManager = $this->get('sonata.media.manager.media');
$media = new Media();
$media->setContext($context);
$media->setProviderName('sonata.media.provider.image');
$media->setBinaryContent($file);
$mediaManager->save($media);
return $media;
}
and get file by this
$file = $request->files->get('newsImage',null);
$media = $this->saveImageMediaBundle($file,'news');
I'm trying to create a user sign up form in WordPress theme. I searched allot and found a solution which was using a non WordPress php file to insert into database. I've created a file "user-register.PHP" to register users from static page. but some how I cannot access that file getting "Page not found error". I'm using WordPress underscores theme.
sign up form Code:
<form id="user_form" name="user_form" method="POST" action="../user-register.php">
<input type="text" placeholder="Your Name" id="user_name" name="user_name">
<input type="email" placeholder="Your Email" id="user_email" name="user_email">
<input type="password" placeholder="Your Password" id="You Password">
<button name="sign-up" id="sign-up">Sing Up</button>
</form>
user-register.php
$user_name=$_POST['user_name'];
$user_email=$_POST['user-email'];
$user_pass=$_POST['user-pass'];
$con=mysqli_connect('localhost', 'kaizen_it', '', wp_site_user);
if($con){
$query='insert into wp_site_user(name,email,password)values(,$user_name,$user_email,$user_pass)';
mysqli_query($con, $query);
mysqli_close($con);
header("Location: http://localhost/wordpress/registered.php");
}
Any help would be appreciated!
Since you're not creating a custom page template for this, your path should be the absolute path to your login file. Assuming this file is in the root of your theme:
<form id="user_form" name="user_form" method="POST" action="<?php echo get_template_directory_uri() . '/user-register.php'; ?>">
Which will render as:
<form id="user_form" name="user_form" method="POST" action="http://example.com/wp-content/themes/sometheme/user-register.php'; ?>">
This path will need to change if your login file isn't in the root of your parent theme.
I have 2 Problem:
1- Picture Path "C:\pic\1.jpg" not added
2- Also i want make a copy of 1.jpg to mysite/img
<Form action="addgallery.php" method="post" enctype="multipart/form-data">
<input type="file" name="file_upload" />
<input type="submit" name="smbit" value="Save" /></Form>
<?php require_once('db.php');
if($_POST['smbit']){
$name=basename($_FILES['file_upload']['name']);
$t_name=$_FILES['file_upload']['tmp_name'];
$dir='img';
if(move_uploaded_file($t_name,$dir."/".$name))
{
if(mysql_query("insert into pics (pid,pfile) values (' ','$_FILES[pfile]')"))
echo 'File Upload Sucessfully';
}
else
{
echo 'Upload Failed!';
}
}
?>
$filep="img/".$_FILES["file_upload"]["name"];
copy($_FILES["pfile"]["tmp_name"],$filep); mysql_query("INSERT INTO
pics(pid,pfile) VALUES(' ','$filep')",$cn);
I have two files the one which hosts my actual contact form and then a file where i post the form to.
contactform.php (which is part of the footer template)
<form id="contact" action="<?php bloginfo('template_url'); ?>/sendmail.php" method="post">
<label for="name">Your name: *</label>
<input type="text" id="nameinput" name="name" value=""/>
<label for="email">Your email: *</label>
<input type="text" id="emailinput" name="email" value=""/>
<label for="comment">Your message: *</label>
<textarea cols="20" rows="7" id="commentinput" name="comment"> </textarea><br />
</form>
sendmail.php
<?PHP
if(isset($_POST['submit'])) {
error_reporting(E_NOTICE);
function valid_email($str)
{
return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*#([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;
}
if($_POST['name']!='' && $_POST['email']!='' && valid_email($_POST['email'])==TRUE && strlen($_POST['comment'])>1)
{
$to = preg_replace("([\r\n])", "", hexstr($_POST['receiver']));
$from = preg_replace("([\r\n])", "", $_POST['email']);
$subject = "Website contact message from ".$_POST['name'];
$message = $_POST['comment'];
$match = "/(bcc:|cc:|content\-type:)/i";
if (preg_match($match, $to) ||
preg_match($match, $from) ||
preg_match($match, $message)) {
die("Header injection detected.");
}
$headers = "From: ".$from."\r\n";
$headers .= "Reply-to: ".$from."\r\n";
if(wp_mail($to, $subject, $message, $headers,'',true))
{
echo 1; //SUCCESS
}
else {
echo 2; //FAILURE - server failure
}
}
else {
echo 3; //FAILURE - not valid email
}
}else{
die("Direct access not allowed!");
}
function hexstr($hexstr) {
$hexstr = str_replace(' ', '', $hexstr);
$hexstr = str_replace('\x', '', $hexstr);
$retstr = pack('H*', $hexstr);
return $retstr;
}
?>
The issue is that this does not know of wp_mail function. I know that I need to include something so wp_mail will be available but what do I add? The function does exist. The issue with including the file that has wp_mail defined is that inside that function it requires some core php functions (wp_mail is being overwritten by cimy_swift plugin)
hi why not try just submitting the form to the base wpurl? then within your header.php file copy and paste your code in?
ie: using a hidden field you can check to see if its been posts, in this case the hidden field is called 'action' and it has a value of 'sendemail'.
form
<form id="contact" action="<?php bloginfo('wpurl'); ?>" method="post">
//form stuff
<input type="hidden" name="action" value="sendemail" />
</form>
Header.php
within the header file we do a call to check and see if the form has been posted,
<html>
<head>
<title><?php wp_title();?></title>
<?php
if( isset($_POST['action']) && ($_POST['action']=='sendemail') ) {
// run your code
}
?>
</head>
if you dont want to go down that route, and wish to use your theme folder to hold the php script then what to is, include the below in your sendmail.php file
define('WP_USE_THEMES', FALSE);
require('../../../wp-blog-header.php');
//above is assuming your file is located in the theme root, not a sub folder.
this will give you access to all the wordpress functions and shortcodes etc..etc..
hope that helps a little..
Marty