Search Results

Search found 208 results on 9 pages for 'enctype'.

Page 4/9 | < Previous Page | 1 2 3 4 5 6 7 8 9  | Next Page >

  • Form File Upload with other TextBox Inputs + Creating Custom Form Action attribute

    - by Jonathan Stowell
    Hi All, I am attempting to create a form where a user is able to enter your typical form values textboxes etc, but also upload a file as part of the form submission. This is my View code it can be seen that the File upload is identified by the MCF id: <% using (Html.BeginForm("Create", "Problem", FormMethod.Post, new { id = "ProblemForm", enctype = "multipart/form-data" })) {%> <p> <label for="StudentEmail">Student Email (*)</label> <br /> <%= Html.TextBox("StudentEmail", Model.Problem.StudentEmail, new { size = "30", maxlength=26 })%> <%= Html.ValidationMessage("StudentEmail", "*") %> </p> <p> <label for="Type">Communication Type (*)</label> <br /> <%= Html.DropDownList("Type") %> <%= Html.ValidationMessage("Type", "*") %> </p> <p> <label for="ProblemDateTime">Problem Date (*)</label> <br /> <%= Html.TextBox("ProblemDateTime", String.Format("{0:d}", Model.Problem.ProblemDateTime), new { maxlength = 10 })%> <%= Html.ValidationMessage("ProblemDateTime", "*") %> </p> <p> <label for="ProblemCategory">Problem Category (* OR Problem Outline)</label> <br /> <%= Html.DropDownList("ProblemCategory", null, "Please Select...")%> <%= Html.ValidationMessage("ProblemCategory", "*")%> </p> <p> <label for="ProblemOutline">Problem Outline (* OR Problem Category)</label> <br /> <%= Html.TextArea("ProblemOutline", Model.Problem.ProblemOutline, 6, 75, new { maxlength = 255 })%> <%= Html.ValidationMessage("ProblemOutline", "*") %> </p> <p> <label for="MCF">Mitigating Circumstance Form</label> <br /> <input id="MCF" type="file" /> <%= Html.ValidationMessage("MCF", "*") %> </p> <p> <label for="MCL">Mitigating Circumstance Level</label> <br /> <%= Html.DropDownList("MCL") %> <%= Html.ValidationMessage("MCL", "*") %> </p> <p> <label for="AbsentFrom">Date Absent From</label> <br /> <%= Html.TextBox("AbsentFrom", String.Format("{0:d}", Model.Problem.AbsentFrom), new { maxlength = 10 })%> <%= Html.ValidationMessage("AbsentFrom", "*") %> </p> <p> <label for="AbsentUntil">Date Absent Until</label> <br /> <%= Html.TextBox("AbsentUntil", String.Format("{0:d}", Model.Problem.AbsentUntil), new { maxlength = 10 })%> <%= Html.ValidationMessage("AbsentUntil", "*") %> </p> <p> <label for="AssessmentID">Assessment Extension</label> <br /> <%= Html.DropDownList("AssessmentID") %> <%= Html.ValidationMessage("AssessmentID", "*") %> <%= Html.TextBox("DateUntil", String.Format("{0:d}", Model.AssessmentExtension.DateUntil), new { maxlength = 16 })%> <%= Html.ValidationMessage("DateUntil", "*") %> </p> <p> <label for="Details">Assessment Extension Details</label> <br /> <%= Html.TextArea("Details", Model.AssessmentExtension.Details, 6, 75, new { maxlength = 255 })%> <%= Html.ValidationMessage("Details", "*") %> </p> <p> <label for="RequestedFollowUp">Requested Follow Up</label> <br /> <%= Html.TextBox("RequestedFollowUp", String.Format("{0:d}", Model.Problem.RequestedFollowUp), new { maxlength = 16 })%> <%= Html.ValidationMessage("RequestedFollowUp", "*") %> </p> <p> <label for="StaffEmail">Staff</label> <br /> <%= Html.ListBox("StaffEmail", Model.StaffEmail, new { @class = "multiselect" })%> <%= Html.ValidationMessage("StaffEmail", "*")%> </p> <p> <input class="button" type="submit" value="Create Problem" /> </p> This is my controller code: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(Problem problem, AssessmentExtension assessmentExtension, Staff staffMember, HttpPostedFileBase file, string[] StaffEmail) { if (ModelState.IsValid) { try { Student student = studentRepository.GetStudent(problem.StudentEmail); Staff currentUserStaffMember = staffRepository.GetStaffWindowsLogon(User.Identity.Name); var fileName = Path.Combine(Request.MapPath("~/App_Data"), Path.GetFileName(file.FileName)); file.SaveAs(@"C:\Temp\" + fileName); if (problem.RequestedFollowUp.HasValue) { String meetingName = student.FirstName + " " + student.LastName + " " + "Mitigating Circumstance Meeting"; OutlookAppointment outlookAppointment = new OutlookAppointment(currentUserStaffMember.Email, meetingName, (DateTime)problem.RequestedFollowUp, (DateTime)problem.RequestedFollowUp.Value.AddMinutes(30)); } problemRepository.Add(problem); problemRepository.Save(); if (assessmentExtension.DateUntil != null) { assessmentExtension.ProblemID = problem.ProblemID; assessmentExtensionRepository.Add(assessmentExtension); assessmentExtensionRepository.Save(); } ProblemPrivacy problemPrivacy = new ProblemPrivacy(); problemPrivacy.ProblemID = problem.ProblemID; problemPrivacy.StaffEmail = currentUserStaffMember.Email; problemPrivacyRepository.Add(problemPrivacy); if (StaffEmail != null) { for (int i = 0; i < StaffEmail.Length; i++) { ProblemPrivacy probPrivacy = new ProblemPrivacy(); probPrivacy.ProblemID = problem.ProblemID; probPrivacy.StaffEmail = StaffEmail[i]; problemPrivacyRepository.Add(probPrivacy); } } problemPrivacyRepository.Save(); return RedirectToAction("Details", "Student", new { id = student.Email }); } catch { ModelState.AddRuleViolations(problem.GetRuleViolations()); } } return View(new ProblemFormViewModel(problem, assessmentExtension, staffMember)); } This form was working correctly before I had to switch to using a non-AJAX file upload, this was due to an issue with Flash when enabling Windows Authentication which I need to use. It appears that when I submit the form the file is not sent and I am unsure as to why? I have also been unsuccessful in finding an example online where a file upload is used in conjunction with other input types. Another query I have is that for Create, and Edit operations I have used a PartialView for my forms to make my application have higher code reuse. The form action is normally generated by just using: Html.BeginForm() And this populates the action depending on which Url is being used Edit or Create. However when populating HTML attributes you have to provide a action and controller value to pass HTML attributes. using (Html.BeginForm("Create", "Problem", FormMethod.Post, new { id = "ProblemForm", enctype = "multipart/form-data" })) Is it possible to somehow populate the action and controller value depending on the URL to maintain code reuse? Thinking about it whilst typing this I could set two values in the original controller action request view data and then just populate the value using the viewdata values? Any help on these two issues would be appreciated, I'm new to asp.net mvc :-) Thanks, Jon

    Read the article

  • Zend form and dynamic file upload

    - by DoomStone
    Hello there i'm trying to create a form with Zend_Form that will enable my user to upload a unlited number of files to my site, witch is done by javascript. Something like <script type="text/javascript"> $(document).ready(function(){ var image_uploade_i = 0; $('#upload_more').click(function() { image_uploade_i++; $('#upload_list').append('<div id="image_uploade_id_'+image_uploade_i+'" style="display: none;"><input type="file" name="image[]" /><br /></a>'); $('#image_uploade_id_'+image_uploade_i).slideDown('slow'); }); }); </script> <?=$this->translate('Add images')?> <form action="" method="post" enctype="multipart/form-data"> <div id="upload_list"> <input type="file" name="image[]" /><br /> <input type="file" name="image[]" /><br /> <input type="file" name="image[]" /><br /> </div> <a href="#" id="upload_more"><?=$this->translate('Upload another image')?></a><br /> <input type="submit" name="image_uploade" value="<?=$this->translate('Upload images')?>" /> </form> But i'm am unable to find out how i can create something like this with Zend_From, the only reason i want to use Zend_Form on this thoug is for validation of the uploadet files. $element = new Zend_Form_Element_File('image'); $element->setRequired(true) ->setLabel('Profile image') ->setDestination($store) ->setValueDisabled(true) ->addValidator(new Zend_Validate_File_ImageSize(array( 'minheight' => 100, 'minwidth' => 150, 'maxheight' => 1920, 'maxwidth' => 1200))) // File must be below 1.5 Mb ->addValidator(new Zend_Validate_File_FilesSize(array('max' => 1572864))) ->addValidator(new Zend_Validate_File_IsImage()); If any 1 can help me set this up would i be verry great full :D

    Read the article

  • jQuery upload file using jQuery's ajax method (without plugins)

    - by Daniil Harik
    Hello, At moment I want to implement picture upload without using any plug-ins. My upload form looks like this <form action="/Member/UploadPicture" enctype="multipart/form-data" id="uploadform" method="post"> <span style="display: none;"> <div class="upload" id="imgUpl"> <h3>Upload profile picture</h3> <div class="clear5"></div> <input type="file" name="file" id="file" /> <button class="btn-bl" id="upComplete"><span>Upload</span></button> </div> </span> </form> And my jQuery code is: $('#upComplete').click(function () { $('#up').hide(); $('#upRes').show(); var form = $("#uploadform"); $.ajax({ type: "POST", url: "/Member/UploadPicture", data: form.serialize(), success: function (data) { alert(data); } }); $.fancybox.close(); return false; }); If I open firebug, I can see that ajax() method does simple form post (not multi-part) and POST content is empty Is it possible to do files upload using jQuery ajax() method or should I do this in any other way? Thank You very much

    Read the article

  • Uploadify plugin doesn't call Java Servlet

    - by sergionni
    Hello,i just started using Uploadify flash plugin instead of standard HTML UI. And met the next problem: when I click "Upload Files" link,that progress is shown and "completed" status is appeared, but in reality - it didn't happened anything,Java Servlet isn't called from backend. There is upload servlet and uploading performed next way earlier: < form enctype="multipart/form-data" method="post" target="uploadFrame" action="<%= request.getContextPath() %>/uploadFile?portletId=${portletId}&remoteFolder=${remoteFolder}">... After providing Uploadify plugin, UI now looks like: plugin part(configuration): <script> ... oScript.text+= "$j('#uploadify').uploadify({"; oScript.text+= "'uploader' : 'kne-portlets/js/lib/uploadify/scripts/uploadify.swf',"; oScript.text+= "'script' : '<%= request.getContextPath() %>/uploadFile?portletId=${portletId}&remoteFolder=<%= decodedString %>',"; oScript.text+= "'cancelImg': 'kne-portlets/js/lib/uploadify/cancel.png',"; oScript.text+= "'folder' : '<%= decodedString %>',"; oScript.text+= "'queueID' : 'fileQueue',"; oScript.text+= "'auto' : false,"; oScript.text+= "'multi' : false,"; //oScript.text+= "'sizeLimit' : 1000"; oScript.text+= "});"; oScript.text+= "});"; ... </script> 'scripts' parameter here points to Java Servlet on backend <%= decodedString %> is folder path, which value is \\file-srv\demo part for uploading: <input type="file" name="uploadify" id="uploadify" /> <a href="javascript:$j('#uploadify').uploadifyUpload();">Upload Files</a> Where is my fault? 'Script' param in plugin config points to Java Servlet on backend and it's done,but Servlet isn't triggered. error, when 'script' param isn't correct:http://img190.imageshack.us/i/errormm.png/ Thank you for assistance.

    Read the article

  • PHP file form question

    - by Jordan Pagaduan
    My Code : <?php function dbAdd($first_name , $image) { //mysql connect database code... mysql_query("INSERT INTO users SET first_name = '".$first_name."', image = '".$image."'"); $mysql_close($sql); } if($_SERVER['REQUEST_METHOD']=='POST') { dbAdd($_POST['first_name'], $_POST['image']); } ?> <form enctype="multipart/form-data" method="post" action=""> First Name : <input type="text" name="first_name" > Image : <input type="file" name="image"> <input type="submit"> </form> The form "file" is to upload. I know that. But I wonder how to get the values so I can put the path of image in the database. The code is already working. The $first_name can already save to the database. Thank you for the answers. Jordan Pagaduan

    Read the article

  • Django Upload form to S3 img and form validation

    - by citadelgrad
    I'm fairly new to both Django and Python. This is my first time using forms and upload files with django. I can get the uploads and saves to the database to work fine but it fails to valid email or check if the users selected a file to upload. I've spent a lot of time reading documentation trying to figure this out. Thanks! views.py def submit_photo(request): if request.method == 'POST': def store_in_s3(filename, content): conn = S3Connection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) bucket = conn.create_bucket(AWS_STORAGE_BUCKET_NAME) mime = mimetypes.guess_type(filename)[0] k = Key(bucket) k.key = filename k.set_metadata("Content-Type", mime) k.set_contents_from_file(content) k.set_acl('public-read') if imghdr.what(request.FILES['image_url']): qw = request.FILES['image_url'] filename = qw.name image = filename content = qw.file url = "http://bpd-public.s3.amazonaws.com/" + image data = {image_url : url, user_email : request.POST['user_email'], user_twittername : request.POST['user_twittername'], user_website : request.POST['user_website'], user_desc : request.POST['user_desc']} s = BeerPhotos(data) if s.is_valid(): #import pdb; pdb.set_trace() s.save() store_in_s3(filename, content) return HttpResponseRedirect(reverse('photos.views.thanks')) return s.errors else: return errors else: form = BeerPhotoForm() return render_to_response('photos/submit_photos.html', locals(),context_instance=RequestContext(request) forms.py class BeerPhotoForm(forms.Form): image_url = forms.ImageField(widget=forms.FileInput, required=True,label='Beer',help_text='Select a image of no more than 2MB.') user_email = forms.EmailField(required=True,help_text='Please type a valid e-mail address.') user_twittername = forms.CharField() user_website = forms.URLField(max_length=128,) user_desc = forms.CharField(required=True,widget=forms.Textarea,label='Description',) template.html <div id="stylized" class="myform"> <form action="." method="post" enctype="multipart/form-data" width="450px"> <h1>Photo Submission</h1> {% for field in form %} {{ field.errors }} {{ field.label_tag }} {{ field }} {% endfor %} <label><span>Click here</span></label> <input type="submit" class="greenbutton" value="Submit your Photo" /> </form> </div>

    Read the article

  • Is jQuery.parseJSON able to process all valid json?

    - by murze
    This piece of valid json (it has been generated using php's json_encode): {"html":"form is NOT valid<form id=\"articleform\" enctype=\"application\/x-www-form-urlencoded\" method=\"post\" action=\"\"><dl class=\"zend_form\">\n<dt id=\"title-label\">&nbsp;<\/dt>\n<dd id=\"title-element\">\n<input type=\"text\" name=\"title\" id=\"title\" value=\"Artikel K\"><\/dd>\n<dt id=\"articleFormSubmitted-label\">&nbsp;<\/dt>\n<dd id=\"articleFormSubmitted-element\">\n<input type=\"hidden\" name=\"articleFormSubmitted\" value=\"1\" id=\"articleFormSubmitted\"><\/dd>\n<dt id=\"submit-label\">&nbsp;<\/dt><dd id=\"submit-element\">\n<input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Bewaar artikel\" onclick=\"this.value='Bezig...';\"><\/dd><\/dl><\/form><script type=\"text\/javascript\">\n\t $(\"#articleform\").submit(function(){\n $.post(\"\/admin\/ajax\/contenttree\/node\/9\/ajaxtarget\/ajaxContainer\", $(\"#articleform\").serialize(), function(html){$(\"#ajaxContainer\").html(html);} );\n\t\t return false;\n\t });\n\n <\/script>","newNodeName":""} is giving jQuery.parseJSON(data) and me a hard time. With this piece of code: alert('start'); alert(data); jQuery.parseJSON(data) alert('stop'); I get a message start and then the data (jsonstring above) is shown. The message "stop" never appears. When I use this json: {"html":"test","newNodeName":""} I've verified that my first big chick of json is valid. Why isn't it processed by jQuery.parseJSON Are there any special characters that don't go well with json?

    Read the article

  • jQuery AJAX call not working in Webkit

    - by Brian
    I've run into a strange issue with Webkit based browsers (both Safari and Chrome - I'm testing on a Mac) and I am not sure what is causing it. Here's a small script I've created that replicates the issue: <html> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" language="javascript"> function doRequest() { document.test.submit(); $.ajax({ type: "GET", cache: false, url: 'ajax.php?tmp=1', success: doSuccess }); } function doSuccess(t_data,t_status,req) { alert('Data is: '+ t_data +', XMLHTTPRequest status is: '+ req.status); } </script> </head> <body> <form name="test" method="post" action="ajax.html" enctype="multipart/form-data"> <input type="file" name="file_1"> <br><input type="button" value="upload" onclick="doRequest();"> </form> </body> </html> ajax.php is: <?php echo $_REQUEST['tmp']; ?> This works as is on Firefox, but the XMLHTTPRequest status is always "0" on both Safari and Chrome. If I remove this line: document.test.submit(); then it works, but of course the form is not submitted. I've tried changing the form submit button from "button" to "submit", but that also prevents it from working on Safari or Chrome. What I am trying to accomplish is: submit the form call another script to get status on the file being uploaded via the form (it's for a small upload progress meter). Any help is really appreciated - I'm hopeful it is just a quirk I'm not familiar with. Thanks! Brian

    Read the article

  • How to upload a file with watir and IE?

    - by karlthorwald
    I am writing a watir script to test an upload form. But the script does not automatically choose the file that is to be uploaded from my harddrive. Instead IE stops with the file chooser dialog open. As soon as I manually select the to be uploaded file in the dialog and click ok, watir continues as desired. I wonder why it stops. This is from my watir script: ie.file_field(:name, 'upload').set("s:\\localwatir\\Test_Pdf.pdf") ie.button(:name, 'submit').click I got the code from this page: http://wiki.openqa.org/display/WTR/File+Uploads This is the form: <form name="form1" enctype="multipart/form-data" method="post" action="uploadlegacy.php"> <input type="file" name="upload" size="30"> <input type="submit" name="submit" value="upload"> </form> I have found this manual http://svn.openqa.org/svn/watir/trunk/watir/unittests/filefield_test.rb also, but as I do not know what $htmlRoot stands for, I cannot really follow it. Does that mean, I have to put some "file///" into the parameter for set()? If so, how exactly? I am using IE 6 for the testing.

    Read the article

  • RedirectToAction and validate MVC 2

    - by Dan
    Hi, my problem is the View where the user typed, the validation. I have to take RedirectToAction on the site because on the site upload a file. Thats my code. My model class public class Person { [Required(ErrorMessage= "Please enter name")] public string name { get; set; } } My View <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MvcWebRole1.Models.Person>" %> Name <h2>Information Data</h2> <%= Html.ValidationSummary() %> <%using (Html.BeginForm ("upload","Home", FormMethod.Post, new{ enctype ="multipart/form-data" })) {%> <fieldset> <legend>Fields</legend> <p> <label for="name">name:</label> <%= Html.TextBox("name") %> <%= Html.ValidationMessage("name", "*") %> </p> </fieldset> <% } %> and the Controller [AcceptVerbs(HttpVerbs.Post)] public ActionResult upload(FormCollection form) { Person lastname = new Person(); lastname.name = form["name"]; return RedirectToAction("Index"); } Thx for answer my question In advance

    Read the article

  • Django Form Preview

    - by Mark Kecko
    I'm trying to use django's FormPreview and I can't get it to work properly. Here's my code: forms.py class MyForm(forms.ModelForm): status = forms.TypedChoiceField( coerce=int, choices=LIST_STATUS, label="type", widget=forms.RadioSelect ) description = forms.CharField(widget = forms.Textarea) stage = forms.CharField() def __init__(self, useradd=None, *args, **kwargs): super(MyForm, self).__init__(*args, **kwargs) self.fields['firm'].label = "Firm" class Meta: model = MyModel fields = ['status', 'description', 'stage'] class MyFormPreview(FormPreview): form_template = 'templates/post.html' preview_template = 'templates/review.html' def process_preview(self, request, cleaned_data): print "processed" def done(self, request, cleaned_data): print "done" # Do something with the cleaned_data, then redirect # to a "success" page. return HttpResponseRedirect('/') urls.py (r'^post/$', MyFormPreview(MyForm)), post.html <form id = "post_ad" action = "" method = "POST" enctype="multipart/form-data"> <table> {{form.as_table}} </table> <input type="submit" name="save" value="Post" /> </form> When I go to /post/ I get the correct form and I fill it out. When I submit the form it goes right back to /post/ but but there are no errors (I've tried displaying {{errors}}) and the form is empty. None of my print statements execute. I'm not sure what I'm missing. Can anyone help me out? I can't find any documentation besides what's on the django site. Also, what's the "preview" variable called that I should use in my preview.html template? {{preview}} or do I just do {{form}} again? -- Answered below. I tried adding 'django.contrib.formtools' to my installed_apps in settings and I tried using the code from the default form templates from django.contrib as suggested below. Still, when I submit the form I go right back to the post template, none of my print statements execute :(

    Read the article

  • JQuery Validation Plugin: Prevent validation issue on nested form

    - by Majid
    I have a form on which I use validation. This form has a section for photo upload. Initially this section contains six elements with the following code: <img class="photo_upload" src="image/app/photo_upload.jpg"> I have bound a function to the click event for the class of photo_upload. This function replaces the image with a minimal form with this code: Copy code <form onsubmit="startUploadImage();" target="control_target" enctype="multipart/form-data" method="post" action="index.php"> <input type="hidden" value="add_image" name="service"> <input type="hidden" value="1000000" name="MAX_FILE_SIZE"> <input type="file" size="10" name="photo" id="photo_file_upload"><br> <button onclick="javascript:cancel_photo_upload();return false;">Cancel</button> </form> So, essentially, after the image is clicked, I'd have a new form nested in my original, validated form. Now, when I use this new form and upload an image, I receive an error (repeated three times) saying: validator is undefined http://host.com/path/index.php Line 286 What is going on here? My guess is this Submit event bubbles up to the outer form As we have validation on that form, validation is triggered, Validation tries to find the form triggering it, Since we have not bound validation to the inner form it returns 'undefined' Now, is my assessment correct? Whether it is or not, how can I solve this issue?

    Read the article

  • How to Upload a file from client to server using OFBIZ?

    - by SIVAKUMAR.J
    Hi all, Im new to ofbiz.So is my question is have any mistake forgive me for my mistakes.Im new to ofbiz so i did not know some terminologies in ofbiz.Sometimes my question is not clear because of lack of knowledge in ofbiz.So try to understand my question and give me a good solution with respect to my level.Because some solutions are in very high level cannot able to understand for me.So please give the solution with good examples. My problem is i created a project inside the ofbiz/hot-deploy folder namely "productionmgntSystem".Inside the folder "ofbiz\hot-deploy\productionmgntSystem\webapp\productionmgntSystem" i created a .ftl file namely "app_details_1.ftl" .The following are the coding of this file <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> <script TYPE="TEXT/JAVASCRIPT" language=""JAVASCRIPT"> function uploadFile() { //alert("Before calling upload.jsp"); window.location='<@ofbizUrl>testing_service1</@ofbizUrl>' } </script> </head> <!-- <form action="<@ofbizUrl>testing_service1</@ofbizUrl>" enctype="multipart/form-data" name="app_details_frm"> --> <form action="<@ofbizUrl>logout1</@ofbizUrl>" enctype="multipart/form-data" name="app_details_frm"> <center style="height: 299px; "> <table border="0" style="height: 177px; width: 788px"> <tr style="height: 115px; "> <td style="width: 103px; "> <td style="width: 413px; "><h1>APPLICATION DETAILS</h1> <td style="width: 55px; "> </tr> <tr> <td style="width: 125px; ">Application name : </td> <td> <input name="app_name_txt" id="txt_1" value=" " /> </td> </tr> <tr> <td style="width: 125px; ">Excell sheet &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: </td> <td> <input type="file" name="filename"/> </td> </tr> <tr> <td> <!-- <input type="button" name="logout1_cmd" value="Logout" onclick="logout1()"/> --> <input type="submit" name="logout_cmd" value="logout"/> </td> <td> <!-- <input type="submit" name="upload_cmd" value="Submit" /> --> <input type="button" name="upload1_cmd" value="Upload" onclick="uploadFile()"/> </td> </tr> </table> </center> </form> </html> the following coding is present in the file "ofbiz\hot-deploy\productionmgntSystem\webapp\productionmgntSystem\WEB-INF\controller.xml" ...... ....... ........ <request-map uri="testing_service1"> <security https="true" auth="true"/> <event type="java" path="org.ofbiz.productionmgntSystem.web_app_req.WebServices1" invoke="testingService"/> <response name="ok" type="view" value="ok_view"/> <response name="exception" type="view" value="exception_view"/> </request-map> .......... ............ .......... <view-map name="ok_view" type="ftl" page="ok_view.ftl"/> <view-map name="exception_view" type="ftl" page="exception_view.ftl"/> ................ ............. ............. The following are the coding present in the file "ofbiz\hot-deploy\productionmgntSystem\src\org\ofbiz\productionmgntSystem\web_app_req\WebServices1.java" package org.ofbiz.productionmgntSystem.web_app_req; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.DataInputStream; import java.io.FileOutputStream; import java.io.IOException; public class WebServices1 { public static String testingService(HttpServletRequest request, HttpServletResponse response) { //int i=0; String result="ok"; System.out.println("\n\n\t*************************************\n\tInside WebServices1.testingService(HttpServletRequest request, HttpServletResponse response)- Start"); String contentType=request.getContentType(); System.out.println("\n\n\t*************************************\n\tInside WebServices1.testingService(HttpServletRequest request, HttpServletResponse response)- contentType : "+contentType); String str=new String(); // response.setContentType("text/html"); //PrintWriter writer; if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0)) { System.out.println("\n\n\t**********************************\n\tInside WebServices1.testingService(HttpServletRequest request, HttpServletResponse response) after if (contentType != null)"); try { // writer=response.getWriter(); System.out.println("\n\n\t**********************************\n\tInside WebServices1.testingService(HttpServletRequest request, HttpServletResponse response) - try Start"); DataInputStream in = new DataInputStream(request.getInputStream()); int formDataLength = request.getContentLength(); byte dataBytes[] = new byte[formDataLength]; int byteRead = 0; int totalBytesRead = 0; //this loop converting the uploaded file into byte code while (totalBytesRead < formDataLength) { byteRead = in.read(dataBytes, totalBytesRead,formDataLength); totalBytesRead += byteRead; } String file = new String(dataBytes); //for saving the file name String saveFile = file.substring(file.indexOf("filename=\"") + 10); saveFile = saveFile.substring(0, saveFile.indexOf("\n")); saveFile = saveFile.substring(saveFile.lastIndexOf("\\")+ 1,saveFile.indexOf("\"")); int lastIndex = contentType.lastIndexOf("="); String boundary = contentType.substring(lastIndex + 1,contentType.length()); int pos; //extracting the index of file pos = file.indexOf("filename=\""); pos = file.indexOf("\n", pos) + 1; pos = file.indexOf("\n", pos) + 1; pos = file.indexOf("\n", pos) + 1; int boundaryLocation = file.indexOf(boundary, pos) - 4; int startPos = ((file.substring(0, pos)).getBytes()).length; int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length; //creating a new file with the same name and writing the content in new file FileOutputStream fileOut = new FileOutputStream("/"+saveFile); fileOut.write(dataBytes, startPos, (endPos - startPos)); fileOut.flush(); fileOut.close(); System.out.println("\n\n\t**********************************\n\tInside WebServices1.testingService(HttpServletRequest request, HttpServletResponse response) - try End"); } catch(IOException ioe) { System.out.println("\n\n\t*********************************\n\tInside WebServices1.testingService(HttpServletRequest request, HttpServletResponse response) - Catch IOException"); //ioe.printStackTrace(); return("exception"); } catch(Exception ex) { System.out.println("\n\n\t*********************************\n\tInside WebServices1.testingService(HttpServletRequest request, HttpServletResponse response) - Catch Exception"); return("exception"); } } else { System.out.println("\n\n\t********************************\n\tInside WebServices1.testingService(HttpServletRequest request, HttpServletResponse response) else part"); result="exception"; } System.out.println("\n\n\t*************************************\n\tInside WebServices1.testingService(HttpServletRequest request, HttpServletResponse response)- End"); return(result); } } I want to upload a file to the server.The file is get from user "<input type="file"..> tag in the "app_details_1.ftl" file & it is updated into the server by using the method "testingService(HttpServletRequest request, HttpServletResponse response)" in the class "WebServices1".But the file is not uploaded. Give me a good solution for uploading a file to the server. Thanks & Regards, Sivakumar.J

    Read the article

  • Why can't upload three files with FileUpload ?

    - by Valter Henrique
    Hi everyone, i'm trying to upload three images to my server, is working, but upload always the last file selected by the user, not the three selected. Here's my code: protected void doPost(HttpServletRequest request, HttpServletResponse response){ boolean multipart = ServletFileUpload.isMultipartContent(request); if (multipart) { DiskFileItemFactory fileItemFactory = new DiskFileItemFactory(); fileItemFactory.setSizeThreshold(5 * 1024 * 1024); //5 MB fileItemFactory.setRepository(tmpDir); ServletFileUpload uploadHandler = new ServletFileUpload(fileItemFactory); try { List items = uploadHandler.parseRequest(request); Iterator itr = items.iterator(); while (itr.hasNext()) { FileItem item = (FileItem) itr.next(); File file = new File(dir, generateNewName()); item.write(file); } } catch (FileUploadException ex) { } catch (Exception ex) { } } } -- UPDATE: <html> <head> <title>Upload</title> </head> <body> <form action="Upload" method="post" enctype="multipart/form-data"> <input type="file" name="file1" /> <br /> <input type="file" name="file2" /> <br /> <input type="file" name="file3" /> <br /> <input type="submit" value="Enviar" /> </form> </body> </html> Best regards, Valter Henrique.

    Read the article

  • jquery ajax form plugin submit multiple times to the server only when using IE6

    - by Dino
    I all. I have the following form used to temporarily upload a photo on a j2ee server and then crop it with imageAreaSelect plugin : <form name="formAvatarName" id="formAvatar" method="post" action="../admin/admin-avatar-upload" enctype="multipart/form-data"> <label>Upload a Picture of Yourself</label> <input type="file" name="upload" id="upload" size="20" /> <input type="button" id="formAvatarSubmit" value="formAvatar" onclick="invia()"/> </form> I am using jquery form plugin to do ajax submission, this is my last :) attempt : $('#formAvatar').unbind('submit').bind('submit', function() { alert('aho'); $(this).ajaxSubmit(options); return false; }); Only when tested with IE6 I can see that the sumbission to the server is done multiple times (first time I got the uploaded file, the other times the sumbmission seems empty and I got error). With IE7, IE8, FFOX, CHROME is working fine. Any Ideas? Many thank in advance!

    Read the article

  • SWFUpload Authentication

    - by durilai
    I am using SWFUpload to do file uploading in a ASP.NET MVC 1.0 website. It is working fine, but I am not able to authenticate the upload method. The HttpContext.User.Identity.Name returns an empty string. I am assuming this is because the Flash movie is making the post. I am also using the wrapper provided here: http://blog.codeville.net/2008/11/24/jquery-ajax-uploader-plugin-with-progress-bar/. The controller action below gets fired, but as mentiond above the user object is not passed. Any help is appreciated! View HTML <form enctype="multipart/form-data" method="post" action="/Media/Upload/Photo"> <input type="file" id="userPhoto_Photo" name="userPhoto_Photo" /> </form> Javascript $(function() { $("#userPhoto").makeAsyncUploader({ upload_url: '/Media/Upload', flash_url: '<%= Url.Content("~/Content/Flash/swfUpload-2.2.0.1.swf") %>', file_size_limit: '1 MB', file_types: '*.jpg; *.png; *.gif', button_action: SWFUpload.BUTTON_ACTION.SELECT_FILE, button_width: 210, button_height: 35, button_image_url: '<%= Url.Content("~/Content/Images/UploadPhoto.png") %>', button_text: '', button_cursor: SWFUpload.CURSOR.HAND, button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT }); }); Controller Action [AcceptVerbs(HttpVerbs.Post)] public ActionResult Upload() { if (Request.Files.Count == 1) { //Upload work } return RedirectToAction("Index", "Profile"); }

    Read the article

  • Form not sending full data

    - by gAMBOOKa
    I have a form with over 50 input fields. The input fields are divided into 5 jquery jabs within the form container. Here's a sample of what it looks like: <form action="admin/save" method="post" enctype="multipart/form-data"> <input type="hidden" name="type" value="department" /> <input type="hidden" name="id" value="21" /> <div id="tabs"> <ul> <li><a href="#tab-1">Tab 1</a><li> <li><a href="#tab-2">Tab 2</a><li> <li><a href="#tab-3">Tab 3</a><li> </ul> <div id="tab-1"> <label>Name</label> <input type="text" name="user-name" /> </div> <div id="tab-2"> <label>Address</label> <input type="text" name="user-address" /> </div> <div id="tab-3"> <label>Phone</label> <input type="text" name="user-phone" /> </div> </div> <input type="submit" value="Send" /> </form> I'm using PHP's Kohana framework, so admin maps to a controller, and save maps to the method action_save. When I output the $_POST variables in action_save, only 'type' and 'id' show up, all the other fields don't seem to submit their data. What could I be doing wrong?

    Read the article

  • Django formset doesn't validate

    - by tsoporan
    Hello, I am trying to save a formset but it seems to be bypassing is_valid() even though there are required fields. To test this I have a simple form: class AlbumForm(forms.Form): name = forms.CharField(required=True) The view: @login_required def add_album(request, artist): artist = Artist.objects.get(slug__iexact=artist) AlbumFormSet = formset_factory(AlbumForm) if request.method == 'POST': formset = AlbumFormSet(request.POST, request.FILES) if formset.is_valid(): return HttpResponse('worked') else: formset = AlbumFormSet() return render_to_response('submissions/addalbum.html', { 'artist': artist, 'formset': formset, }, context_instance=RequestContext(request)) And the template: <form action="" method="post" enctype="multipart/form-data">{% csrf_token %} {{ formset.management_form }} {% for form in formset.forms %} <ul class="addalbumlist"> {% for field in form %} <li> {{ field.label_tag }} {{ field }} {{ field.errors }} </li> {% endfor %} </ul> {% endfor %} <div class="inpwrap"> <input type="button" value="add another"> <input type="submit" value="add"> </div> </form> What ends up happening is I hit "add" without entering a name then HttpResponse('worked') get's called seemingly assuming it's a valid form. I might be missing something here, but I can't see what's wrong. What I want to happen is, just like any other form if the field is required to spit out an error if its not filled in. Any ideas?

    Read the article

  • MVC 4 Beta with Mobile Project FIle Upload does not work

    - by Jim Shaffer
    I am playing around with the new MVC 4 beta release. I created a new web project using the Mobile Application template. I simply added a controller and a view to upload a file, but the file is always null in the action result. Is this a bug, or am I doing something wrong? Controller Code: using System.IO; using System.Web; using System.Web.Mvc; namespace MobileWebExample.Controllers { public class FileUploadController : Controller { public ActionResult Index() { return View(); } [AllowAnonymous] [HttpPost] [AcceptVerbs(HttpVerbs.Post)] public ActionResult Upload(HttpPostedFileBase file) { int i = Request.Files.Count; if (file != null) { if (file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName); file.SaveAs(path); } } return RedirectToAction("Index"); } } } And the view looks like this: @{ ViewBag.Title = "Index"; } <h2>Index</h2> <form action="@Url.Action("Upload")" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" /> <input type="submit" value="Submit" /> </form>

    Read the article

  • JSF don't find component in view root with the form id

    - by kenzokujpn
    I have a t:inputFileUpload inside the form, in the html of the display page the id of this component is form:inputFile but when I tried to get the component from the view root using "form:inputFile" the return is null, but when the "form:" is removed the return is the component. The component don't set the value in my managed bean, someone have this problem? EDIT: <h:form id="form" enctype="multipart/form-data"> <t:inputFileUpload id="inputFile" size="40" value="#{managedBean.inputFile}"/> </h:form> In the managed bean: private UploadedFile inputFile; with the gets and sets provided by Eclipse. //This method scans the view root and returns the component with the id passed as parameter findComponentInRoot("form:inputFile"); This returns null, but when I use: //This method scans the view root and returns the component with the id passed as parameter findComponentInRoot("inputFile"); The return is the component I'm looking for, but when I use the View Source in Internet Explorer the id of this component is "form:inputFile". I don't know if this is related, but the component don't set the value in my managed bean and it's strange the fact that the id of the component is different from the HTML source. I'm using JSF 1.2 Mojarra. Someone else has this problem? Or know why this happens?

    Read the article

  • uploading image & getting back from database

    - by Anup Prakash
    Putting a set of code which is pushing image to database and fetching back from database: <!-- <?php error_reporting(0); // Connect to database $errmsg = ""; if (! @mysql_connect("localhost","root","")) { $errmsg = "Cannot connect to database"; } @mysql_select_db("test"); $q = <<<CREATE create table image ( pid int primary key not null auto_increment, title text, imgdata longblob, friend text) CREATE; @mysql_query($q); // Insert any new image into database if (isset($_POST['submit'])) { move_uploaded_file($_FILES['imagefile']['tmp_name'],"latest.img"); $instr = fopen("latest.img","rb"); $image = addslashes(fread($instr,filesize("latest.img"))); if (strlen($instr) < 149000) { $image_query="insert into image (title, imgdata,friend) values (\"". $_REQUEST['title']. "\", \"". $image. "\",'".$_REQUEST['friend']."')"; mysql_query ($image_query) or die("query error"); } else { $errmsg = "Too large!"; } $resultbytes=''; // Find out about latest image $query = "select * from image where pid=1"; $result = @mysql_query("$query"); $resultrow = @mysql_fetch_assoc($result); $gotten = @mysql_query("select * from image order by pid desc limit 1"); if ($row = @mysql_fetch_assoc($gotten)) { $title = htmlspecialchars($row[title]); $bytes = $row[imgdata]; $resultbytes = $row[imgdata]; $friend=$row[friend]; } else { $errmsg = "There is no image in the database yet"; $title = "no database image available"; // Put up a picture of our training centre $instr = fopen("../wellimg/ctco.jpg","rb"); $bytes = fread($instr,filesize("../wellimg/ctco.jpg")); } if ($resultbytes!='') { echo $resultbytes; } } ?> <html> <head> <title>Upload an image to a database</title> </head> <body bgcolor="#FFFF66"> <form enctype="multipart/form-data" name="file_upload" method="post"> <center> <div id="image" align="center"> <h2>Heres the latest picture</h2> <font color=red><?php echo $errmsg; ?></font> <b><?php echo $title ?></center> </div> <hr> <h2>Please upload a new picture and title</h2> <table align="center"> <tr> <td>Select image to upload: </td> <td><input type="file" name="imagefile"></td> </tr> <tr> <td>Enter the title for picture: </td> <td><input type="text" name="title"></td> </tr> <tr> <td>Enter your friend's name:</td> <td><input type="text" name="friend"></td> </tr> <tr> <td><input type="submit" name="submit" value="submit"></td> <td></td> </tr> </table> </form> </body> </html> --> Above set of code has one problem. The problem is whenever i pressing the "submit" button. It is just displaying the image on a page. But it is leaving all the html codes. even any new line message after the // Printing image on browser echo $resultbytes; //************************// So, for this i put this set of code in html tag: This is other sample code: <!-- <?php error_reporting(0); // Connect to database $errmsg = ""; if (! @mysql_connect("localhost","root","")) { $errmsg = "Cannot connect to database"; } @mysql_select_db("test"); $q = <<<CREATE create table image ( pid int primary key not null auto_increment, title text, imgdata longblob, friend text) CREATE; @mysql_query($q); // Insert any new image into database if (isset($_POST['submit'])) { move_uploaded_file($_FILES['imagefile']['tmp_name'],"latest.img"); $instr = fopen("latest.img","rb"); $image = addslashes(fread($instr,filesize("latest.img"))); if (strlen($instr) < 149000) { $image_query="insert into image (title, imgdata,friend) values (\"". $_REQUEST['title']. "\", \"". $image. "\",'".$_REQUEST['friend']."')"; mysql_query ($image_query) or die("query error"); } else { $errmsg = "Too large!"; } $resultbytes=''; // Find out about latest image $query = "select * from image where pid=1"; $result = @mysql_query("$query"); $resultrow = @mysql_fetch_assoc($result); $gotten = @mysql_query("select * from image order by pid desc limit 1"); if ($row = @mysql_fetch_assoc($gotten)) { $title = htmlspecialchars($row[title]); $bytes = $row[imgdata]; $resultbytes = $row[imgdata]; $friend=$row[friend]; } else { $errmsg = "There is no image in the database yet"; $title = "no database image available"; // Put up a picture of our training centre $instr = fopen("../wellimg/ctco.jpg","rb"); $bytes = fread($instr,filesize("../wellimg/ctco.jpg")); } } ?> <html> <head> <title>Upload an image to a database</title> </head> <body bgcolor="#FFFF66"> <form enctype="multipart/form-data" name="file_upload" method="post"> <center> <div id="image" align="center"> <h2>Heres the latest picture</h2> <?php if ($resultbytes!='') { // Printing image on browser echo $resultbytes; } ?> <font color=red><?php echo $errmsg; ?></font> <b><?php echo $title ?></center> </div> <hr> <h2>Please upload a new picture and title</h2> <table align="center"> <tr> <td>Select image to upload: </td> <td><input type="file" name="imagefile"></td> </tr> <tr> <td>Enter the title for picture: </td> <td><input type="text" name="title"></td> </tr> <tr> <td>Enter your friend's name:</td> <td><input type="text" name="friend"></td> </tr> <tr> <td><input type="submit" name="submit" value="submit"></td> <td></td> </tr> </table> </form> </body> </html> --> ** But in this It is showing the image in format of special charaters and digits. 1) So, Please help me to print the image with some HTML code. So that i can print it in my form to display the image. 2) Is there any way to convert the database image into real image, so that i can store it into my hard-disk and call it from tag? Please help me.

    Read the article

  • PHP File Upload using url parameters

    - by Arthur
    Is there a way to upload a file to server using php and the filename in a parameter (instead using a submit form), something like this: myserver/upload.php?file=c:\example.txt Im using a local server, so i dont have problems with filesize limit or upload function, and i have a code to upload file using a form <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html> <body> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="fileForm" enctype="multipart/form-data"> File to upload: <table> <tr><td><input name="upfile" type="file"></td></tr> <tr><td><input type="submit" name="submitBtn" value="Upload"></td></tr> </table> </form> <?php if (isset($_POST['submitBtn'])){ // Define the upload location $target_path = "c:\\"; // Create the file name with path $target_path = $target_path . basename( $_FILES['upfile']['name']); // Try to move the file from the temporay directory to the defined. if(move_uploaded_file($_FILES['upfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['upfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } } ?> </body> Thanks for the help

    Read the article

  • how to update div tag in javascript with data from model for onsubmit form asp.net mvc

    - by michael
    In my page i have a form tag which submits to server ,gets data and redirects to same page. problem is the the div tag which has the data from server is not getting updated. how to do that in javascript <% using (Html.BeginForm("Addfile", "uploadfile", FormMethod.Post, new { id = "uploadform", enctype = "multipart/form-data" })) { %> <input type="file" id="addedFile" name="addedFile" /><br /> <input type="submit" id="addfile" value="Addfile" /> <div id="MyGrid"> //data from the model(server side) filelist is not updating</div> what will be the form onsubmit javascript function to update the div tag with the data from the model. and my uploadfile controller get post methods are as [AcceptVerbs(HttpVerbs.Get)] public ActionResult Upload() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public ActionResult AddFile(HttpPostedFileBase addedFile) { static List<string> fileList = new List<string>(); string filename = Path.GetFileName(addedFile.FileName); file.SaveAs(@"D:\Upload\" + filename); fileList.Add(filename); return("Upload",fileList); } thanks, michaela

    Read the article

  • JSP Upload File Java.lang.NullPointer

    - by newbie123
    I want to develope upload and download file from server. Upload.html <form action="/UploadFile/UploadFile" method="POST" enctype="multipart/form-data">Select a file: <input type="submit" name="button" /> <input type="file" name="first"></form> UploadFile.servlet protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String temp = request.getParameter("first"); System.out.println(temp); File origFile = new File(temp); FileOutputStream out = new FileOutputStream(request.getContextPath() + "pdtImages/" + "FirstFile"); InputStream ins = new FileInputStream(origFile); try { System.out.println(request.getContextPath()); byte[] buf = new byte[1024]; int len; while ((len = ins.read(buf)) > 0) { out.write(buf, 0, len); } out.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } When I submitted the file I got null pointer error message. I not very familiar with jsp can anybody help me? I want to store the file to the server directory.

    Read the article

  • PHP - upload.class image and $_FILES

    - by Ockonal
    Hello, I'm using class.upload.php to upload pictures onto the server. Here is my form: <form action="<?="http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];?>" method="post" enctype="multipart/form-data"> <table style="width: 100%; padding-top: 20px;"> <tr> <td>Image file:</td> <td><input type="file" name="image_file" /></td> </tr> <tr> <td>&nbsp;</td> <td align="right"><input type="submit" name="add_new" value="Add image" /><td></td> </tr> </table> </form> In php code I do: if( array_key_exists('add_new', $_POST) ) { echo 'add new is in array'; echo '<pre>'; print_r($_POST); print_r($_FILES); echo '</pre>'; $handle = new Upload($_FILES['image_file']); ... } Here is an output of print_r: Array ( [image_file] => somefile.png [add_new] => Add image ) Array ( ) As you can see second array is empty ($_FILES), so image doesn't upload. Why? operating system : Linux PHP version : 5.2.12 GD version : 2.0.34 supported image types : png jpg gif bmp open_basedir : /home/httpd/vhosts/kz-gbi.ru/httpdocs:/tmp

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9  | Next Page >