I have a page with "File" html input field and a "Submit" button as below:
<form id="formUploadfile" name="formUploadfile" method="post" action="" class="form" enctype="multipart/form-data">
<label for="name"><strong>File</strong></label>
<input type="file" name="uploaded_file" size="35" />
<button type="submit" class="btn_common" id="inquiry_submit" name="inquiry_submit">
Submit
</button>
</form>
I want to send the selected file to a pre-defined email address. In PHP, Do I need to upload the file to my server first before sending it as an attachment email? Or without uploading it to server, it will work.
I Googled but didn't find the answer of above question, please help. If anyone have a code for the same purpose, please provide link.
Thanks
Yes, you will need to upload the file to the server first.
Use a mailing class like Swiftmailer to send the file.
Related
First off, I have no experience with PHP. I'm setting up a form on a site that is hosted on Dotster using their link. This works to send an email with all of the info, but the file that is selected for upload disappears. Does not end up on the server, does not attach to the email. Are there any ways to determine or control where the file goes using their script?
<form method="post" action="https://www1.dotster.com/scripts/formemail.html" enctype="multipart/form-data">
<input type="hidden" name="my_email" value="flyboyjr#gmail.com">
<input type="hidden" name="subject" value="Nomination Form">
<h1>Nominee Information</h1>
<label for="photo">Please upload a photo of the nominee in uniform or sports attire appropriate with
their
nomination. Please make sure it includes a clear view of their face.</label><br><br>
<input type="file" id="photo" name="photo" required>
I am trying to have users use an HTML form to input their email addresses but I would like the addresses to go to a word doc or notepad or a text file on the iPad pro they are entering this all on.
I'm trying to figure out the best method to do this as I'm not using a hosted server.
So far this is what I've been using in my HTML file:
<form action="" method="post>
Name:
<input type="text" name="name">
Email:
<input type="email" name="email">
<input type="submit">
</form>
Can you tell me if I need to incorporate PHP or tell me how to do that? I've tried using POST but kept getting 'Post method not allowed' and if I tried to use GET, I would get an internal server error.
Any help would be greatly appreciated!
I am a beginner in php, I am trying to make a registration form with return to the email, in this form, I would like you to upload the image and send it to the destination email! I've tried innumerable codes to upload php and I can not, could anyone help me? the page in html with the form and input is correct, I would like help for the part of upload.php
my code in html is
`<form name="Form1" id="Form1" action="./upload.php" method="POST" enctype="multipart/form-data">
`<input name="image" type="file" id="image" accept="image/*" capture="camera" onchange="" class="upload">
Is there any method to create this php with parameter of post or session?
I have a file upload form on which I also want to use the Google reCAPTCHA.
If I have the following
<form method="post">
<input type="file" name="filename">
<div class="g-recaptcha" data-sitekey="***"></div>
<input id="submit" name="submit" type="submit" value="Submit">
</form>
the I can use the reCAPTCHA, but cannot upload the file.
However, if I use:
<form method="post" enctype="multipart/form-data">
<input type="file" name="filename">
<div class="g-recaptcha" data-sitekey="***"></div>
<input id="submit" name="submit" type="submit" value="Submit">
</form>
I can upload the file successfully, and use the reCAPTCHA provided that the file is a text file. I cannot get it to work if I try to upload a pdf file.
When uploading a text file, the $_POST contains the 'g-recaptcha-response', but when uploading a pdf, the $_POST does not contain the 'g-recaptcha-response'.
Can someone explain what is going wrong here?
EDIT
It seems like it's actually a filesize problem.
Files larger than ~200kb cannot be sent whatever their format.
I have upload_max_filesize = 2M in my php.ini file, so I'm not sure why 200kb is too large...
Any thoughts?
EDIT 2: More information
It looks like the $_FILE contains the error code 3: UPLOAD_ERR_PARTIAL.
I don't see why the file cannot be uploaded completely.
EDIT 3: Getting somewhere
I can now upload files. It seems like I need to put the reCAPTCHA before the file input.
<form method="post" enctype="multipart/form-data">
<div class="g-recaptcha" data-sitekey="***"></div>
<input type="file" name="filename">
<input id="submit" name="submit" type="submit" value="Submit">
</form>
Can anyone elaborate on why this might be the case?
Edit 4: Spoke too soon
Switching the order makes the g-recaptcha-response' appear in $_POST, but I am still getting the error code 3: UPLOAD_ERR_PARTIAL.
Edit 5
It looks like the file is being uploaded correctly, since I can see it in the header parameters (firefox debugger). It seems like php is just not filling in the $_FILE array properly...
I tried the same code on a different server and it worked fine.
Looks like the problem was that the server I set up has some sort of configuration issue. It actually has nothing to do with the interaction of reCAPTCHA and the file input + enctype.
I will update if I figure out what the configuration problem is.
Hello I needed code for automatically chose file and upload it to desired link. How to do that?
html code:
<html>
<head><title>Uploading</title></head>
<body>
<form method="post" enctype="multipart/form-data" action="uploadFile.php">
<input type="file" name="file" id="file">
<input type="submit" value="Submit">
</form>
</body>
</html>]
In above code at this line
<input type="file" name="file" id="file">
this path is fixed and can't be changed as user tries. so when user click on "Submit" button the file has to upload.
How to do this?
TL;DR: What you are trying to do is absolutely impossible - for a good reason.
If this was possible, you could create a hidden upload field pointing to a file containing valuable data (e.g. the browser's cookie database) and submit the form using JavaScript (or make the user submit it without knowing about that upload) and copy any file the user has access to.