Cloudinary direct browser upload failed when i dynamically set attribute 'data-form-data' of upload input

with this code the upload is done correctly

<script>
var data = { "timestamp": "1403951115",
"callback": "http://localhost:8080/SimpleServlet/cloudinary_cors.html",
"signature": "3b1a708393db7cd0ef1df2be0c602ea99d9c64c3",
"api_key": "742866863611915" };
$('#uploadinput').attr('data-form-data', JSON.stringify(data));
</script>

if i set dinamically value for 'data-form-data' attribute the upload fail with error: "Upload preset Must specify upload preset when using unsigned upload"

Note that i set dinamically data value using an ajax asynchronous call to cloudinary server to take the credentials.

Answers


Modifying the parameters of the cloudinary-fileupload field by calling $(...).attr('data-form-data', json) does not work since the value of this attribute is not re-read after initialization, so this call has no effect. Possible consequences are 401 Unauthorized (e.g. because of Unknown API Key) error and the original parameters being used.

The correct way to update the upload parameters is to call $(...).fileupload({formData: data}) where data is the parameters hash (not JSON serialized).


To avoid this issue and to start from, I have used the following approach:

<script src="//widget.cloudinary.com/global/all.js" type="text/javascript"></script>
<script>
    cloudinary.setCloudName('YOUR_CLOUD_NAME');
    cloudinary.openUploadWidget({upload_preset: 'your_unsigned_preset_name'}, function(error, result) {//...
    })
</script>

Need Your Help

SQLSTATE: Syntax error or access violation: 1064 You have an error in your SQL syntax — PHP — PDO

php sql mysql pdo mysql-error-1064

I've looked through all the other stackoverflow (and google) posts with the same problem, but none seemed to address my problem.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.