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
Related
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<input type="text" id="TEXTBOX1_ID"></input>
<input type="button" id="button1" value="Add"onclick="add_element_to_array()"></input>
<input type="button" id="button2" value="Display" onclick="display_array()"</input>
<script src="js/app-functions.js"</script>
</body>
</html>
the above code contains two buttons and onclick they use a function from a js file. However once I press any of the bottoms it does nothing a piece of text is meant to appear, I don't think it is my js code as It very simple and I have made sure it's not a syntax error.
you missed to > in script.it didn't include file .
corrected:
<script src="js/app-functions.js"></script>
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>
I have downloaded jquery-validation-1.14.0.zip file from web. And know I am trying to use it in my project, but the problem with me is i don't know exactly where to place the folder(extracted file) in my wamp folder, and what are the changes to be made on any of the config or .htaccess file. As i have given all my complete 3-4 days to configure it by my own, but finally left with no options and i am posting my question here so that anyone here can help me out.
basically here is my
folder sructure;-
C:\wamp\www\developer\jquery-validation
controller:-
C:\wamp\www\developer\application\controllers
How do i use to call the script file in my view:-
<html>
<head>
<script type="text/javascript" src ="../jquery-validation/lib/jquery.js"> </script>
<script type="text/javascript" src ="../jquery-validation/dist/jquery.validate.js"> </script>
</head>
And another thing that i would like to emphasis here is, in eclipse-mars, i have included jquery library too. And now i have jquery 2.0 library inside Javascript Resources.
After doing all these when i simply try to use alert function, i got to see lots of errors.
Errors:-
GET
http://localhost/developer/index.php/jquery-validation/lib/jquery.js [HTTP/1.1 404 Not Found 27ms]
GET
http://localhost/developer/index.php/jquery-validation/dist/jquery.validate.js [HTTP/1.1 404 Not Found 30ms]
ReferenceError: $ is not defined
Please get me rid of all these anyhow.. Now i'm totally frustrated..
Very Very Thanks in advance..
the problem remains the same #praveen and # ichadhr. For more clarification of my code, here is a simple view:
<html>
<head>
<script type="text/javascript" src ="<?php echo base_url('jquery-validation/lib/jquery.js');?>" ></script>
<script type="text/javascript" src ="<?php echo base_url('jquery-validation/dist/jquery.validate.js');?>"></script>
</head>
<body>
<form method="post" id="myform">
<div class="form-group">
<label for="name">Name:</label>
<input type="text" class="form-control" name="name" id="name">
</div>
<button type="submit" class="btn btn-default" id="sub">Submit</button>
</form>
<script>
$("#sub").click(function(){
alert("hello");
$("#myform").valid();
});
</script>
</body>
</html>
And my base url is localhost/developer
and the folder and file locations for js file are as in my code.
Errors are still same
All included assets bind with
base_url('path/to/script.js');
And all links generate with
site_url('controller/action/param');
After Seeing your new description assuming files are in your views folder inside application So the becomes :-
<html>
<head>
<script type="text/javascript" src ="<?php echo base_url('jquery-validation/lib/jquery.js');?>" ></script>
<script type="text/javascript" src ="<?php echo base_url('jquery-validation/dist/jquery.validate.js');?>"></script>
</head>
<body>
<form method="post" id="myform">
<div class="form-group">
<label for="name">Name:</label>
<input type="text" class="form-control" name="name" id="name">
</div>
<button type="submit" class="btn btn-default" id="sub">Submit</button>
</form>
<script>
jQuery(document).ready(function($){
$("#sub").click(function(){
alert("hello");
});
});
</script>
</body>
</html>
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.
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.