I tried following the example at:
http://www.plupload.com/example_custom.php
But in the request, file is not sent to the method of the controller, only the name.
Maybe I need to set in the configuration of Plupload, something like 'multipart = true'
Any idea?
The question was ages ago. But will answer for other people looking for a solution.
The solution for this is adding "multipart : true" on your pluploadQueue({}) function. That would send the file as multipart. For multiple files, it will send/POST the request multiple times. Then you can handle that on your controller.
Hope this helps.
Jas
I have no experience with Plupload I don't think you should have to explicitly deal with multipart uploads in the plugin configuration. (That is a file uploader library after all.) Don't get me wrong but do you have the multipart attribute set to true in the html markup?
W3C states this for file upload...
<FORM action="http://server.com/cgi/handle"
enctype="multipart/form-data"
method="post">
<P>
What is your name? <INPUT type="text" name="submit-name"><BR>
What files are you sending? <INPUT type="file" name="files"><BR>
<INPUT type="submit" value="Send"> <INPUT type="reset">
</FORM>
Can we see some more code. There's a lot that could be going wrong.
Also, can you use debugger after the form submission and post a params output here?
J
P.s. By the way, tried to make this a comment but no go...
A few "any" ideas... :-p
Is there any chance the file you try to upload gets filtered by some security feature in Rails, the rails-proxying server (apache?), or even some software on clientside?
Did you try different browsers, to verify it's not a clientside problem? (sniffing your network connection could be another way to verify that the file actually gets sent to the server)
If you happen to be using rack, then there is some middleware that can take care of file uploads for you. Not what you wanted, but perhaps useful as a temporary workaround while waiting in case you'd discover you have to wait for some bugfixing in rails or plupload.
Permissions on the folder where uploaded files are supposed to go? Or do they go in memory first, and write to disk later? Maybe the plupload library uses temporary files somewhere and the permissions aren't working out there.
Related
I need to browse to a folder to get the directory name by clicking a button, is there any way of getting this? I was thinking I could achieve this by using <input type="file" />
For security reasons you cant. You can get just the file name, the rest is handled by the browser.
Answered here https://stackoverflow.com/a/15201258/1248388
More documentation on the File API https://developer.mozilla.org/en/docs/Using_files_from_web_applications
I'm wondering. Is there any way to upload picture to the server with using javascript(jquery)?
And save picture path(name) into database?
I'm running Windows platform server in asp .net 1.1. (I'm remaking 10years old web page) There are absolutely no chance to use php that I know well..
Thanks for all comments, I'm pretty desperate..
You can't directly upload/insert into the database with javascript, you will need some server side code to handle where the file is saved and inserting into the database.
With that said there are a couple options.
First you have traditional forms - <input type="file" />
Secondly you have Drag/Drop and <input type="file" /> dataTransfer object, which contain the base64 encoded version of the binary data from those files. Here is a quick example: http://www.html5rocks.com/en/tutorials/dnd/basics/
Hope that helps!
http://msdn.microsoft.com/en-us/library/aa479405.aspx
The above link details how you can upload a file using ASP.NET. I don't think you necessarily need Javascript/JQuery unless you're doing some validation on the type or trying to do some additional UI stuff with the uploader.
I have the following html on a form:
<input type="file" name="uploadField" />
When users click on the browse button they can select any file but I want to rename the file using the value of another field on the form
I have a submit button. Can I do it here?
Can I do it here?
No, for security reasons you have no control of this on the client. You can rename the file on the server when it gets uploaded.
I know the question is old but if anyone is still struggling with similar problem, please try to use append() or set() method of the FormData.
for security reasons you cannot do such thing i.e. manipulate multipart file or file to be uploaded do that on server
Is there any way I can do that? For example, I have an
<input type="file" id="upload_file" />
Obviously I can't just
$('#upload_file').val('http://www.site.com/path/to/image.jpg').parent().submit();
You can't do it.
Javascript won't let you read from other domains (for security reasons).
File inputs don't accept URL inputs (or for that matter paths) AFAIK.
I can't see how you will get this to work. What server side language are you using? Would it not be better to just make a direct request for the remote file from the server?
IF that site supports what are you trying to do it should work.
Most of file uploads are very strict, as you can't just upload a file wherever you want even if you know the upload script.
If host supports sending a link to the picture and he knows what to do with it ... I don't see why your script should not work.
<form method="post" action="http://www.example.org/">
<input type="text" name="upload_file" id="upload_file" value="" />
<input type="submit" onclick="$('#upload_file').val('http://www.example.org/example.jpg');">
</form>
Te begin with, you cannot do file uploads without a server-side tool. Sending a file to the server is pointless if there isn't anything on the side other to receive it.
Said that, if you already have a server-side language available and a file that's publicly reachable at a URL, the server-side language is perfectly capable of fetching the file by its own means. There's no need to use the browser as intermediary. You just need to send the URL in a regular <input type="text"> element.
If the file is not publicly reachable, e.g., it belongs to an intranet or is password-protected, it's probably simpler to instruct the user to type the URL in the browser's "Open file" dialoque. In many cases, the browser will download the file and fill the <input type="file"> control with the temporary downloaded file.
I need to know how to get full path from fileupload using javascript,
I tried using the following coding but of no use
<input type="file" id="picField" onchange="preview(this)">
<script type="text/javascript">
function preview(test){
var source=test.value;
alert(source);
}
</script>
but in the alert message, i am getting only
Filename.extension
I am not getting full path, but it is showing full path in File Upload box please help how to solve this problem
Thanks
This is a browser security restriction, in modern browsers you cannot get the full client file-system path of the selected file, nor set a path programmatically...
Maybe for security reason, javascript doesn't allow this to happen. And if you come to think of it, Server side pages cannot access your local files. Not that I have a solution for your question.
Actually, there is some kind of solution.
Albeit, it will help only if you can run Electron desktop app on local machine: https://stackoverflow.com/a/59990858/9390914