794: Can not add screenshot
- Fixed
- Review Board
david.b********@gmai***** (Google Code) (Is this you? Claim this profile.) | |
|
|
Jan. 6, 2009 |
What's the URL of the page containing the problem? http://<server>/reviewboard/r/6/ What steps will reproduce the problem? 1. Click "Add screenshot". 2. Click on the "Caption:" field to set focus and type "test". 3. Click "Path:" field, a file browser opens. 4. Choose a picture file (png, jpg...). The filed contains the path to the file. 5. Click Upload. What is the expected output? What do you see instead? Expected : well, file upload starts. Obtained : Two error messages 1. Above the two fields: "One or more fields had errors". 2. After "Path:" field : "This field is required.". What operating system are you using? What browser? Windows XP, FF 3.0.5 and Linux Kubuntu, FF 3.0.X. Same problem on both.
I forgot information : Repeated clicks on "Upload" button pile up "This field is required." messages after "Path:" fields.
On your installation, does the web server have write permissions to your site's htdocs/media/uploaded tree? (recursively)
-
+ NeedInfo
I can confirm this issue locally. Wireshark and Firebug both confirm the fully-filled-in form is being posted with only one parameter, "dummy" (which has no value). I notice that the submit button is not nested within the form element, but I'm not sure that's required. I'm still investigating.
In common.js, it looks like the formDlg function was never finished. The function rbApiCall gets called with 'data' not set. /* * Sends the form data to the server. */ function send() { if(console) console.log("in send", options); rbApiCall({ path: options.path, buttons: $("input", self.modalBox("buttons")), errorPrefix: "Saving the form failed due to a server error:", success: function(rsp) { if(console) console.log("in send success", rsp); checkForErrors(rsp); } }); } ... function rbApiCall(options) { if (options.buttons) { options.buttons.attr("disabled", true); } $.ajax({ type: options.type || "POST", url: options.url || (SITE_ROOT + "api/json" + options.path), data: options.data || {dummy: ""}, dataType: options.dataType || "json", success: options.success, error: function(xhr, textStatus, errorThrown) { ...
Note, this problem also prevents me from accessing "Update Diff" functionality, so it seems to be consistent for all uses of formDlg (currently, only Update Diff and Attach Screenshot). The following very crude patch seems to work for me: if the previously-ignored 'upload' flag is set, this turns the AJAX call into a standard form post. The real fix is probably to use a jQuery/YUI upload widget and/or implement iframe fun. Note that form.submit was never being activated before my change (the existing code trapped the submit button to do AJAX and returned false, blocking real form submission), so I removed the 'submit' trap to allow my hack to work. Index: htdocs/media/rb/js/common.js =================================================================== --- htdocs/media/rb/js/common.js (revision 1666) +++ htdocs/media/rb/js/common.js (working copy) @@ -170,10 +170,8 @@ var form = $("<form/>") .attr("action", options.action) - .submit(function(e) { - send(); - return false; - }) + .attr("method", "POST") // ignored for non-uploads + .attr("enctype", "multipart/form-data") // ignored for non-uploads .append($("<table/>") .append($("<colgroup/>") .append('<col/>') @@ -235,8 +233,8 @@ $('<input type="button"/>') .val(options.confirmLabel) .click(function() { - send(); - return false; +if(console) console.log("submitting from box", "this", this, "self", self, "form", form); + return send(form); }) ] }); @@ -248,15 +246,26 @@ /* * Sends the form data to the server. */ - function send() { + function send(f) { +if(console) console.log("in send", options); + + if( options.upload && f ) { + var a = options.url || (SITE_ROOT + "api/json" + options.path); + $(f).attr("action", a); +if(console) console.log("submitting...", f); + f.submit(); // ugly: this will redirect the user to a JSON reply + return true; + } rbApiCall({ path: options.path, buttons: $("input", self.modalBox("buttons")), errorPrefix: "Saving the form failed due to a server error:", success: function(rsp) { +if(console) console.log("in send success", rsp); checkForErrors(rsp); } }); + return false; } I'll also note that I was blocked from uploading some valid JPEG files, but that is probably a separate issue (to be filed once images can be uploaded).
Yeah, somehow this didn't get finished. Oops :/ I've been working on it today but have hit some bug in my fix that I'm still trying to figure out.
-
- NeedInfo + Confirmed -
- Priority-Medium + Priority-Critical + Component-Reviews + Milestone-Release1.0 -
+ chipx86
Okay, this should be fixed in r1668. This missed the nightly build, but I'll build a new one in a minute.
-
- Confirmed + Fixed
chipx86: Write permissions are given to apache in the upload directory. timw.at.work: Thank you for the technical analysis and patches. I'm glad the root cause is found. Thank you for this valuable tool.
Works for me, too. I noticed the screenshot thumbnails not being generated, but that turned out to be a stale config entry in the database (in the Admin->Database->Sites->site, there was a reference to the old media directory).