Uploading image should be stored on DB with Bit (Encoded)? - javascript

This code run but the image was not display
why the image was not display
<html>
<head>
<title> img bit</title>
</head>
<body>
<form action="backend.php" method="POST" enctype="multipart/form-data">
<input type="file" name="file"/>
<br />
<input type="submit"/>
</form>
</body>
</html>

This has nothing to do with encryption. enctype refers to encoding, not encryption. The distinction between encryption and encoding is very important!
enctype="multipart/form-data" is what I've used on the <form> tag in every functioning file upload system I've ever written.
What does backend.php do? That's almost certainly where your problem lies if your files aren't uploading.

Related

How does this HTML method = "POST" tag work?

I recently started a project that was going to download some data from a certain site. Unfortunately, when I wanted to download html with r.text, I got this code instead of the code I expected:
<html>
<head>
<title>Working...</title>
</head>
<body>
<form method="POST" name="hiddenform" action="some link"><input type="hidden" name="wa" value="wsignin1.0" /><input type="hidden" name="wresult" value="some links tokens and certificates" /><input type="hidden" name="wctx" value="some link" /><noscript><p>Script is disabled. Click Submit to continue.</p><input type="submit" value="Submit" /></noscript></form>
<script language="javascript">
window.setTimeout('document.forms[0].submit()', 0);
</script>
</body>
</html>
When I open this html code in webbrowser it redirects me to a certain site.
Can I send request with python requests module that will work just like that ?
If I did not explain something enough, I would be grateful to write it in a comment.

Safari is the only browser that doesn't update visibility css settings in this simple script until AFTER the file is uploaded. Why?

For some reason the following very simple code will not execute visibility setting in safari until AFTER the file is finished uploading or if a user doesn't put a file into the file input section.
This is the only browser it acts like this in.
Every other browser executes the visibility settings while the file is uploading. Please, can anyone explain why?
ENTIRE SIMPLE PHP FILE CODE
<html>
<head>
<title>Our Industry Alpha 0.01</title>
<script>
function formcheck() {
document.getElementById('i_submit').style.visibility='hidden'; document.getElementById('patience').style.visibility='visible';
}
</script>
</head>
<body>
<form action="" enctype="multipart/form-data" method="post">
<input type="file" required>
<input type="submit" style="visibility:visible;" value="Send" id="i_submit" onclick="formcheck();">
</form>
<div id="patience" style="visibility:hidden;">... UPLOADING ...</div>
</body>
</html>

Cloudinary jQuery File Upload - image not uploading after selection

I'm trying to test the Cloudinary Uploader (via jquery and PHP).
I follow the instructions there:
http://cloudinary.com/documentation/php_image_upload#direct_uploading_from_the_browser
I'm interested to make it work as browser uploading (not server side).
My final HTML/script text is the following (I put some XXXX).
<html>
<head>
<title></title>
<script src="js/jquery-3.1.1.min.js"></script>
<script src='js/jquery.ui.widget.js' type='text/javascript'></script>
<script src='js/jquery.iframe-transport.js' type='text/javascript'></script>
<script src='js/jquery.fileupload.js' type='text/javascript'></script>
<script src='js/jquery.cloudinary.js' type='text/javascript'></script>
</head>
<body>
<script type='text/javascript'>
$.cloudinary.config({"api_key":"XXXXX","cloud_name":"XXXXX"});
</script>
<form action="uploaded.php" method="post">
<input class='cloudinary-fileupload' data-cloudinary-field='image_id' data-form-data='{"timestamp":1477780986,"callback":"http:\/\/www.XXXXX.XXX\/cloudinary\/cloudinary_cors.html","signature":"96872da4909f6acf00537c78ca41414ea73bXXXXX","api_key":"538456726987XXX"}' data-url='https://api.cloudinary.com/v1_1/di2a8qkzv/auto/upload' name='file' type='file'/> <input type="hidden" name="image_id" id="image_id" />
</form>
</body>
</html>
I just click the "Browse..." button and select a file, but nothing happens.
I have also the Firefox Console ON, but also I don't see any action.
As I understand, the form should automatically submit after the selection of the file. Right?
If not, what exact should I do to submit the file to Cloudinary?
What escapes me?
You have to initialize the input field as well. Try adding your code the following:
$('.cloudinary-fileupload').cloudinary_fileupload();
Make sure that this line is loaded last, so either put it at the end of the HTML or put it in a $( document ).ready() block.
On file input append this:
onchange="this.form.submit();"
Change this line of code:
<form action="uploaded.php" method="post">
<input class='cloudinary-fileupload' data-cloudinary-field='image_id' data-form-data='{"timestamp":1477780986,"callback":"http:\/\/www.XXXXX.XXX\/cloudinary\/cloudinary_cors.html","signature":"96872da4909f6acf00537c78ca41414ea73bXXXXX","api_key":"538456726987XXX"}' data-url='https://api.cloudinary.com/v1_1/di2a8qkzv/auto/upload' name='file' type='file'/> <input type="hidden" name="image_id" id="image_id" />
</form>
to:
<form action="uploaded.php" method="post">
<input onchange="this.form.submit();" class='cloudinary-fileupload' data-cloudinary-field='image_id' data-form-data='{"timestamp":1477780986,"callback":"http:\/\/www.XXXXX.XXX\/cloudinary\/cloudinary_cors.html","signature":"96872da4909f6acf00537c78ca41414ea73bXXXXX","api_key":"538456726987XXX"}' data-url='https://api.cloudinary.com/v1_1/di2a8qkzv/auto/upload' name='file' type='file'/> <input type="hidden" name="image_id" id="image_id" />
</form>

save file path in variable with javascript, without fakepath?

Before I have commented that I am using a script in javascript as the following one, to guard the route of a file in a variable, there is any way of doing it, although not using javascript, in order that the mistake does not go out for me of fakepath? I do not want to save the file, only its path.
<html>
<head>
<script>
function CopyMe(oFileInput, sTargetID) {
document.getElementById(sTargetID).value = oFileInput.value;
}
</script>
</head>
<body>
<div>
<input type="file" onchange="CopyMe(this, 'txtFileName');" />
</div>
<div>
You chose: <input id="txtFileName" type="text" readonly="readonly" />
</div>
</body>
</html>
thaks for your help

Firefox ignores JavaScript override of form submit

I have this code
<html>
<head>
<script type="text/javascript" src="my-search.js"></script>
</head>
<body onLoad="my_Init();">
<div>
<form name="id_msearchform" onsubmit="my_EventHandler_Action(); return false;">
<input type="text" name="id_searchphrase" value="example"></input>
<br><br>
<input type="submit" name="id_searchsubmit" value="Search"></input>
</form>
<br><br>
<div id="id_searchresults">No search done...</div>
</div>
</body>
</html>
I don't want the browser to request a new URL. That is why "onsubmit" has "return false;". This code works in Internet Explorer, but Firefox generates a new request. Any ideas what I am doing wrong?
FireBug changes between not wanting to acknowledge there is Javascript reference and showing the Javascript file without any errors... I will update this when i have more to add. I will try various thingsm e.g. try upload it to the net and see if FireFox behaves differently when not running JS on local disk.
Are you sure that you haven't got any errors?
I try with a simple html:
<html>
<head>
<script type="text/javascript" src="my-search.js"></script>
</head>
<body onLoad="my_Init();">
<div>
<form name="id_msearchform" onsubmit="my_EventHandler_Action(); return false;">
<input type="text" name="id_searchphrase" value="example"></input>
<br><br>
<input type="submit" name="id_searchsubmit" value="Search"></input>
</form>
<br><br>
<div id="id_searchresults">No search done...</div>
</div>
</body>
</html>
And a simple javascript called my-search.js in the same path of my html with the next code:
var my_Init = function(){
alert('Hello Onload');
}
var my_EventHandler_Action = function(){
alert('Hello OnSubmit');
}
And it works fine.
Can you show a live demo (with dropbox or something)?
Instead of using a submit button, try using a button and link the javascript function to that.

Categories