Dropzone Hidden Field Working Intermittently - dropzone.js

I have a basic dropzone form:
<form action="/library/annual-equipment-requests/upload-files" class="dropzone">
<input name="record" type="hidden" value="Value">
<div class="fallback">
<input name="file" type="file" multiple="">
</div>
</form>
This works sometimes and not others. When it does work, I can see the post data in the network developer tools result:
Request Payload
------WebKitFormBoundaryI7wN7T1SFcHzGC2t
Content-Disposition: form-data; name="record"
Value
------WebKitFormBoundaryI7wN7T1SFcHzGC2t
Content-Disposition: form-data; name="file"; filename="Lighthouse.jpg"
Content-Type: image/jpeg
And when it doesn't work....
Request Payload
------WebKitFormBoundaryI7wN7T1SFcHzGC2t
Content-Disposition: form-data; name="file"; filename="Lighthouse.jpg"
Content-Type: image/jpeg
Any ideas?

Related

How would I get the value from the hidden input using Cypress?

I need to save the token which is stored in this hidden input.
This is my request:
cy.request({
method: 'GET',
url: '/auth/login',
body: {
email: email,
password: password,
},
}).then((response) => {
const page = response.body;
});
The response.body returns:
<!DOCTYPE html>
<html>
<body>
<form class="form" action="" method="post" autocomplete="off">
<input id="email" class="form-control" type="text" name="email" placeholder="Email" />
<input id="password" class="form-control" type="password" name="password" placeholder="Password" />
<input type="hidden" name="_token" value="c5LWQtrMVkKXxBFKs1zFzrJYq4PgNifndvcV0F6O">
<button type="submit">Login</button>
Other Login
</form>
</body>
</html>
I'm not sure how I find/grab the value from the hidden input with the name _token
From the cypress CSRF example:
it('strategy #1: parse token from HTML', function () {
// to fetch the login page, and then parse the HTML contents
// to find the CSRF token embedded in the page
cy.request('/auth/login')
.its('body')
.then((body) => {
// we can use Cypress.$ to parse the string body
// thus enabling us to query into it easily
const $html = Cypress.$(body)
const token = $html.find('input[name=_token]').val()
...[see link for full code]
})

How to test form submission

I have a login form with some html that users fill in:
<form method="post" enctype="multipart/form-data">
<div class="form"><input name="username"> </div>
<div class="form">
<button type="submit">Login</button>
</form>
I would like to test that the username is being received correctly. I am able to send a multipart form however this is contained within the body of the request not as a postform.
form := url.Values{}
form.Set("username", "Bob")
// Create request
req, _ := http.NewRequest("POST", "/login", strings.NewReader(form.Encode())) // sends as multipart form in request body
req.Header.Set("Content-Type", "application/www-form-urlencoded")
testRouter.ServeHTTP(rr, req)
How do I make a request with the form data attached as a Postform so that I can extract it c.Postform("username") from the backend as if submitted via the browser?
keep button in the form with button type submit
<form method="post" enctype="multipart/form-data">
<div class="form">
<input name="username">
<input type="submit" name="submit" value="submit"/>
</div>
</form>
Figured it out. Turns as you can simply do req.PostForm = form....

CodeIgniter post is not working when input value is more 1000 chars

I have a form contains inputs, it works fine till I include the following input field with more 1000 chars value and the problem is the form posts nothing to my controller.
It works fine in my localhost but when I upload it to my remote host the problem is happen.
<form action="controllerName/test" method="post">
<input type="hidden" name="test1" value="1">
<input type="hidden" name="test2" value="2">
<input type="hidden" name="imgBase64" value="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlgAAAGQCAYAAAByNR6YAAAgAElEQVR4nO
......">
<input type="submit" />
</form>
Post Result:
array()
Error:
Forbidden 403

zoho remote api normal form server side code

I am using zoho remote api for normal form, but i get error whenever i try to save my document Please help me to correct my code that is given below
i need help to save my document. every time i save the document get the error "unable post the content"
<form accept-charset="UTF-8" target="_blank" action="https://sheet.zoho.com/remotedoc.im" method="POST">
<input type="hidden" value="http://example.com/demo1/test.csv" name="url">
<input type="hidden" value="**********" name="apikey">
<input type="hidden" value="editor" name="output">
<input type="hidden" value="normaledit" name="mode">
<input type="hidden" value="test.csv" name="filename">
<input type="hidden" value="en" name="lang">
<input type="hidden" value="12345678" name="id">
<input type="hidden" value="csv" name="format">
<input type="hidden" value="save.php" name="saveurl">
<input c type="submit" value="Details" name="submit">
</form>
<?php
$filepath = '/home/spatials/public_html/demo1/'.$_FILES['content']['name'];
$tmp_filename = $_FILES['content']['tmp_name'];
$upload_status = move_uploaded_file($tmp_filename, $filepath);
?>
Pleas correct my code
Wrong Save URL:
<input type="hidden" value="php/save.php" name="saveurl" />
Correct Save URL:
<input type="hidden" name="saveurl" value="http://example.com/demo1/save.php" />
WIKI page link for reference: https://apihelp.wiki.zoho.com/Save-Document.html

Honeypot protection with Ajax

Recently i got attacked by nasty auto-form fill bots which filled my shout form with all sorts of spam. My shout form consist from a html file with 2 textboxes,an ajax script(for refreshing without reloading) and my php file for handling all the inserting data into my DB.
I am thinking implementing a hidden textbox for a minimum protection against these bots but with no luck since i cant pass the honeypot data to my php file. My code:
HTML Form
<form class="form" method="post" action="postdata.php">
<fieldset id="inputs">
<input id="name" name="name" type="text" placeholder="name" maxlength="20">
<textarea id="message" name="message" type="text" placeholder="message" maxlength="255"></textarea>
</fieldset>
<fieldset id="actions">
<input type="submit" id="submit" value="Submit">
</fieldset>
</form>
Ajax script
$(function(){refresh_shoutbox();$("#submit").click(function(){var a=$("#name").val();var b=$("#message").val();var c="name="+a+"&message="+b;$.ajax({type:"POST",url:"postdata.php",data:c,success:function(d){$("#shout").html(d);$("#message").val("");$("#name").val("")}});return false})});
function refresh_shoutbox(){var a="refresh=1";$.ajax({type:"POST",headers:{"cache-control":"no-cache"},url:"postdata.php",data:a,success:function(b){$("#shout").html(b)}})};
postdata.php file
<?php
if($_POST['name'] or $_POST['message']) {
$name= $_POST['name'];
$message= $_POST['message'];
///do other stuff/////
?>
I will insert a hidden field in my html form
<input id="email" name="emails" style="display:none"></br>
but i cant manage to pass the extra value to my existing ajax script.Tried some code but with no luck.
Any help so i can get my shoutbox up and running again?

Resources