Uploading File To MySQL from HTML form via Servlet

Hello all !
I hope this is better place to ask.
I'm working on simple Servlet/Jsp application trying to hold to MVC pattern and got stuck on uploading file to MySQL db.
Here's what I'm trying to accomplish:
1) client submits a JPEG image via a simple html form on a webpage.
2) JPEG is put into a database table, column field of type BLOB.
3) Servlet processes the request, gets a connection to the db and inserts the image into the table.
4) after that user is able to retrieve an image from db and display it in JSP page.
This is pretty much the same task Angela was trying to do here:
http://forum.java.sun.com/thread.jspa?threadID=667597&messageID=3905449
I could use her snippets if i knew what is what and decided to figure out this myself. Aftet some investigation i found out that i need to import org.apache.commons.fileupload.*;which i found here: http://jakarta.apache.org/commons/fileupload/
what am i driving at ?
-----------------------1-----------------------
After first line of code
boolean isPart = FileUpload.isMultipartContent(request);netBeans 5.5 beta2 with bundled Tomcat 5.5.17 underlines this with warning saying that
org.apache.commons.fileupload.FileUploadBase
has been depreceted
is it a reason for concern ?
-----------------------2-----------------------
Is it actually good idea to store images in db as blob ?
what about large ammounts of text ?
thank you
-Dominik

is it a reason for concern ?Yes.
You should take a look at the method in the documentation and find out exact reason for depricating it.
If it is depricated becouse they going to remove it in the future you should use the new alternative method becouse if you use the old method your app will not work in the future releases of the API.
If it is depricated becouse it is not safe to use the method you should clearly understand the risks involved in using the method and see if that can give you any trouble in your project.
-----------------------2-----------------------
Is it actually good idea to store images in db as
blob ?I think that it is ths best option available when you want to store binary data
what about large ammounts of text ?You can use clob columns.
By the way when you store files in the database its better you put some extra columns to store the file name and file type(mime) becouse you cant directly detect those things later by just looking at the data of the file.

Similar Messages

  • JEditorPane can't handle POST from HTML form?

    I posted this before but i never got an answer so i'll try again :-)
    Im running a tomcat server were i have a jsp script that uploads files to the server. What i need to do to is to use a regular java application for the rest of the "project" im working on.
    And i can get the JSP page to be displayed properly using JEditorPane but i cant get the html FORM POST in the JSP to execute... i dont know if theres some limits in JEditorPane or if im just using the wrong type of approach on this one.
    This is the server
    http://chilly-schrimp.kicks-ass.org/uploadbean/SimpleUpload.jsp
    (only works if my computer is turned on)
    Heres the code:
    =======================================================================
    import javax.swing.*;
    import javax.swing.event.*;
    import java.io.*;
    public class JSPtest {
    public static void main(String[] args) {
    JEditorPane pane = null;
    try {
    pane = new JEditorPane("http://chilly-schrimp.kicks-ass.org/uploadbean/SimpleUpload.jsp");
    catch (IOException ex) {
    ex.printStackTrace(System.err);
    System.exit(1);
    pane.setEditable(false);
    // Add a hyperlink listener.
    final JEditorPane finalPane = pane;
    pane.addHyperlinkListener(new HyperlinkListener() {
    public void hyperlinkUpdate(HyperlinkEvent ev) {
    try {
    if (ev.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
    finalPane.setPage(ev.getURL());
    } catch (IOException ex) { ex.printStackTrace(System.err); }
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(new JScrollPane(finalPane));
    frame.setSize(350,400);
    frame.setVisible(true);
    =======================================================================
    any suggestions??
    thanx
    /eric

    I am using request.getParameter(passed variable name)
    to pass data from HTML form to JSP with no problem.
    WHen I try to pass data from HTML form of
    multipart/form-dta type to JSP as following:
    < form enctype="multipart/form-data" name="theForm"
    method="post"
    ACTION="http://titan.ssd.loral.com:7778/ifs/jsp-bin/if
    -cts/stringsecond.jsp">
    The passed value is null. Why?because the jsp most likely does not handling of POST parameters like this.
    How can I pass data successfully from this form to
    JSP?jsp's are not meant to read such amounts of data. this (= uploading) is a typical task for a specialized servlet. there you have full control over input and output. if you need to, you can still forward to a jsp after processing in the servlet.
    How can I pass data from JavaScript to JSP???? i'm not sure what exactly you mean. normally you put it into an url and submit it.
    robert

  • Calling PLSQL Stored Procedure From HTML Form Submit Button

    Hi there,
    I am having a little difficulty with calling a stored procedure using an html form button. Here is the code I have right now...
    HTP.PRINT('<form action=ZWGKERCF.P_confdelete>');
    HTP.PRINT('<input type=''submit'' value='' Yes '' onClick=''document.getElementById("mypopup").style.display="none"''>');
    HTP.PRINT('</form></div>');Here is the issue - I need to find a way to pass variables to this stored procedure so it know what data to operate on. This stored procedure will delete data for a specific database record and I must pass three variables to this procedure to make it work.
    Lets call them class_number, term, conf These three variables will be passed and the data will be deleted and the person will see a confirmation screen once the delete query has been executed.
    So ideally I would want: ZWGKERCF.P_confdelete(class_number, term, conf) and then the stored procedure would handle the rest!
    Seems pretty simple but I am not sure how to make this happen... My thoughts were:
    Pass the data to this html form (the three fields I need) in hidden variables. Then somehow pass these using POST method to the procedure and read using GET?
    Can someone clarify what the best way to do this is? I have a feeling its something small I am missing - but I would really like some expert insight :-)
    Thanks so much in advance!
    - Jeff

    795018 wrote:
    I am having a little difficulty with calling a stored procedure using an html form button. Here is the code I have right now...
    HTP.PRINT('<form action=ZWGKERCF.P_confdelete>');
    HTP.PRINT('<input type=''submit'' value='' Yes '' onClick=''document.getElementById("mypopup").style.display="none"''>');
    HTP.PRINT('</form></div>');Here is the issue - I need to find a way to pass variables to this stored procedure so it know what data to operate on. This stored procedure will delete data for a specific database record and I must pass three variables to this procedure to make it work. The browser generates a POST or a GET for that form action, that includes all the fields defined in that form. Let's say you define HTML text input fields name and surname for the form. The URL generated for that form's submission will be:
    http://../ZWGKERCF.P_confdelete?name=value1&surname=value2The browser therefore submits the values of the form as part of the URL.
    The web server receives this. It sees that the base URL (aka location) is serviced by Oracle's mod_plsql. It passes the URL to this module. This module builds a PL/SQL block and makes the call to Oracle. If we ignore the additional calls it makes (setting up an OWA environment for that Oracle session), this is how the call to Oracle basically looks like:
    begin
      ZWGKERCF.P_confdelete( name=> :value1, surname =>  :value2 );
    end;Thus the PL/SQL web enabled procedure gets all the input fields from the HTML form, via its parameter signature. As you can define parameter values with defaults, you can support variable parameter calls. For example, let's say our procedure also have a birthDate parameter that is default null. The above call will still work (from a HTML form that does not have a date field). And so will the following URL and call that includes a birth date:
    URL:
    http://../ZWGKERCF.P_confdelete?name=value1&surname=value2&birthdate=2000/01/01
    PL/SQL call:
    begin
      ZWGKERCF.P_confdelete( name=> :value1, surname =>  :value2, birthdate => :value3 );
    end;There is also another call method you can use - the flexible 2 parameter interface. In this case the PL/SQL procedure name in the URL is suffixed with an exclamation mark. This instructs the mod_plsql module to put all input field names it received from the web browser into a string array. And put all the values for those fields in another string array. Then it calls your procedure with these arrays as input.
    Your procedure therefore has a fixed parameter signature. Two parameters only. Both are string arrays.
    The advantage of this method is that your procedure can dynamically deal with the web browser's input - any number of fields. The procedure's signature no longer needs to match the HTML form's signature.
    You can also defined RESTful mod_plsql calls to PL/SQL. In which case the call format from the web browser looks different and is handled differently by mod_plsql.
    All this (and more) is detailed in the Oracle manuals dealing with mod_plsql - have a search via http://tahiti.oracle.com (Oracle Documentation Portal) for the relevant manuals for the Oracle version you are using.
    Alternatively, simply download and install Oracle Apex (Application Express). This is a web development and run-time framework and do all the complexities for you - including web state management, optimistic locking, security and so on.

  • Can't pass parameter from HTML form of multipart/form-dta type to JSP

    I am using request.getParameter(passed variable name) to pass data from HTML form to JSP with no problem. WHen I try to pass data from HTML form of multipart/form-dta type to JSP as following:
    < form enctype="multipart/form-data" name="theForm" method="post" ACTION="http://titan.ssd.loral.com:7778/ifs/jsp-bin/ifs-cts/stringsecond.jsp">
    The passed value is null. Why?
    How can I pass data successfully from this form to JSP?
    How can I pass data from JavaScript to JSP?
    Thank you

    I am using request.getParameter(passed variable name)
    to pass data from HTML form to JSP with no problem.
    WHen I try to pass data from HTML form of
    multipart/form-dta type to JSP as following:
    < form enctype="multipart/form-data" name="theForm"
    method="post"
    ACTION="http://titan.ssd.loral.com:7778/ifs/jsp-bin/if
    -cts/stringsecond.jsp">
    The passed value is null. Why?because the jsp most likely does not handling of POST parameters like this.
    How can I pass data successfully from this form to
    JSP?jsp's are not meant to read such amounts of data. this (= uploading) is a typical task for a specialized servlet. there you have full control over input and output. if you need to, you can still forward to a jsp after processing in the servlet.
    How can I pass data from JavaScript to JSP???? i'm not sure what exactly you mean. normally you put it into an url and submit it.
    robert

  • Upload file function in a flash form

    Hi, i need to ad a function to upload files in a tipical
    contact form and receive them by mail.
    anyone knows how to do it? thanks a lot!

    Hey badboy,
    try to be good and search. Anyways as a started refer to the following links.
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/00062266-3aa9-2910-d485-f1088c3a4d71
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/202a850a-58e0-2910-eeb3-bfc3e081257f
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b0e10426-77ca-2910-7eb5-d7d8982cb83f
    New Web Dynpro Java Tutorials - Uploading and Downloading Files in SAP NetWeaver 7.0
    Thanks,
    GLM

  • How to sent importet RAW files into the cloud? The files was importet from Canon EOS via camera adapter to the iPad. The Files was stored in the folder importet. But the files does not sync with photostream.

    How to sent importet RAW files into the cloud? The files was importet from Canon EOS via camera adapter to the iPad. The Files was stored in the folder importet. But the files does not sync with photostream.

    Welcome to the Apple community.
    Only photos taken on the iOS device and after photo stream was enabled will be added to photo stream.

  • To the Adobe MUSE team....Have you considered adding an "Upload File" field for the contact forms?

    To the Adobe MUSE team....Have you considered adding an "Upload File" field for the contact forms?

    But seriously...
    Is there any development being done for this?  I have a careers section on our website that I have been asked to "make easier for applicants" (right now, there is a link that just opens an email).  I'm going to make a full version of an application, but I would really like a way to upload resumes and CV's. 
    I'm going to have to look into some kind of service if this isnt something on the Muse radar.  A reply of some kind would be fantastic! 

  • How to search xml file data based on the given keyword from html form

    hi,
    i'm new to XML. I have this problem regarding searching within a XML file.
    the
    idea is that my search will be based on the keyword entered
    in
    by the user from a HTML form. the keyword is then used to search all
    the
    question nodes and the choice nodes within a XML file. once the match
    is
    found, i will have to display the results.
    But i don't know how to do so - especially the part of searching xml file.
    Can
    anyone help me in this? Your help is much appreciated.
    Edited by: Moti_Lal.D on Apr 4, 2008 7:28 AM

    yeah.. what i was trying to do is
    i have one xml fine. then i have to read all the tag values say
    <book>
    <title>Java</title>
    <author>agarwal</author>
    <price>200</price>
    </book>
    <book>
    <title>Xml</title>
    <author>saxmann</author>
    <price>300</price>
    </book>
    i can read the tag values like this
    File file = new File("dom.xml");
    try {
    DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    Document doc = builder.parse(file);
    NodeList nodes = doc.getElementsByTagName"book");
    for (int i = 0; i < nodes.getLength(); i++) {
    Element element = (Element) nodes.item(i);
    NodeList title = element.getElementsByTagName("title");
    Element line = (Element) title.item(0);
    what i want is i may give any xml file
    like File file = new File("xxx.xml");
    (it may be one level/two level/3level tagged one)
    then the i should read all the tag values and store them in some array. Then when i enter some character from keyboard (say "a") then it has to show all the tag values starts with "a" and display them.
    i guess u understand my problem.

  • JDBC + SERVLET: inserting text data  to access file from Html form

    Hi everybody !
    I'm trying to insert text data from my html form to access database using servlet and jdbc technologies.
    The problem that I'm that the data is TEXT, but not the English language !!!
    So my access db file gets - ???????? symbols instead the real text.
    This is the form line that sending data to my servlet:
    <form
    method="POST"
    ACTION=http://localhost:8080/servlet/myServlet enctype="text/html">
    And this is servlet line that defines response content:
    res.setContentType( "text/html" );
    What can I do to get in access db file the right text format and not a ???????? symbols.
    Maybe I must to ad some <meta ...> , but where ?

    You're dealing with Unicode, I'd guess, and not ASCII.
    I guess I'd have two questions:
    (1) Is the character encoding on your pages set properly for the language you're trying to use?
    (2) Does Access handle Unicode characters?
    Access isn't exacly a world-class database. (If it was, there'd be no reason for M$ to develop SQL Server.) I'd find out if it supports other character sets. If not, you'll have to switch to a more capable database that does. - MOD

  • File upload hanging when called from another form

    Hi
    I have created a file upload form from the documentation I found on metalink and the form works fine on its own. I have then implemented the form into a multi form application and when the file upload form is called from another form it hangs trying to get to the client drive so that it can pick up a file. I have tried using the 'call_form', 'open_form' and 'new_form' built-ins but the results were all the same. Can anybody help me?
    Maria

    Hello,
    This is not the support, so there are no post more urgent than other.
    Francois

  • New! Attachments - Upload files as part of a form submission

    You can now add multiple file attachment fields to your forms to collect  files from respondents. Almost all file formats are supported for upload including audio and video (executable and other such file types are not allowed). All files are virus scanned by the service.
    You can add field restrictions that force respondents to upload files less than a certain size, upload multiple files and/or only upload certain file formats.
    All of the data and files collected are acccessible from the View reponse tab.
    Files from multiple respondents can be downloaded together within a single zip file by the author. When downloading, the author has the option of prefixing a field value to the filenames so they know which respondent submitted a file.
    Attachments is available to both free and paid users, however, the maximum file size of all files submitted by one respondent is 100KB for free users and 20MB for paid users. There is no limit on the amount of overall file storage for a free or paid users.
    Benefits
    You no longer have to manage collecting data and files using different solutions – like filling out the form using FormsCentral and sending the files via email. Files and data can now be collected using a single method and everything is stored in one central place so managing the collection process is much easier.
    Ensure that respondents provide the right number, size and type of files.
    Example Use Cases
    Employment Application – Job applicant needs to submit their resume with their application as a single PDF or Word file.
    College Admission – High school student (or parents) need to submit an essay, high school transcript and reference letters with their admission form.
    Grant Application – Applicant needs to submit a proposal document and pictures (JPG or PNG) of their previous work in order to be eligible for the grant.
    Client Onboarding – Financial advisor needs to collect account information and investment documents from new clients.
    Request for Proposal – Procurement department needs to collect bids from competing vendors. Vendors need to fill out a form with their company’s information, provide certification documentation and a detailed proposal document.
    Conference Registration – Exhibitors and speakers need to provide a JPG or PNG head shot for the conference directory that is less than 1MB in size when registering.
    Change Order – Engineering firm uses a change order form to manage changes to their engineering specs. Change orders routinely include videos, images or other drawings to support the requested change.

    Yes you sure can. 
    Right click in the cell corresponding to the attachment field in the View Responses response table and choose "Insert File" (also in the "Insert" menu).  The column must correspond to an attachment type field or you will not see the "Insert File" option.
    Thanks,
    Josh

  • Store links to uploaded files in mysql database

    Hello. What I'm trying to do is, let a user upload a file to my server, and lets other users download those files. I don't want to store the files in a database, because that will slooow things down. What I was wondering is how I would be able to store links to the files in the database, and let other users view them, and download them. I'm using apache tomcat, and MySQL.
    Any help would be appreciated. Thanks.

    I'm using a .jsp that uploads the files directly to my ROOT.
    This is the code for it:
    <html>
    <head><title>upload</title></head>
    <body>
    <%@ page import="java.io.*"%>
    <%
        String contentType = request.getContentType();
        if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0)) {
                    DataInputStream in = new DataInputStream(request.getInputStream());
                    int formDataLength = request.getContentLength();
                    byte dataBytes[] = new byte[formDataLength];
                    int byteRead = 0;
                    int totalBytesRead = 0;
                  while (totalBytesRead < formDataLength) {
                      byteRead = in.read(dataBytes, totalBytesRead, formDataLength);
                         totalBytesRead += byteRead;
                    String file = new String(dataBytes);
                    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;
                 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;
                    String filepath=session.getServletContext().getRealPath("/")+saveFile;
                    FileOutputStream fileOut = new FileOutputStream(filepath);
                fileOut.write(dataBytes, startPos, (endPos - startPos));
                fileOut.flush();
                fileOut.close();
                out.println("File saved as " +saveFile);
    %>
    <!-- Starts Here -->
    <form method="post" ACTION="upload.jsp" name="uploadForm" ENCTYPE='multipart/form-data'>
    <input type="file" name="uploadfile" />
    <p>
        <input type="submit" name="Submit" value="Submit">
        <input type="reset" name="Reset" value="Reset">
        <input type="hidden" name="action" value="upload">
    </p>
    </form>
    <!-- Ends Here -->
    </body>
    </html>
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Powershell: How do I upload files with metadata from a manifest file?

    I am using the script from this blog to try to upload files into SharePoint, using a manifest file to specify the metadata associated with each file. Right now, the script works, but is not populating
    the metadata from the manifest (xml) file. When I write the $metadataManifest variable out to the console, I get the contents of my xml file, so the code is reading the file when it should. However when it gets to the line in bold ($metadataManifest.Columns.Column),
    it does not go into that block...it just skips on to checkin the file. Again the $metadataManifest variable shows all the content in my xml manifest file. Here is what the script looks like...
    #Get web and document library objects
    $web = Get-SPWeb "http://companySite"
    $Library = "My Library"
    $docLibrary = $web.Lists[$Library]
    $ManifestFilePath = "C:\PowerShellScripts\Manifest.xml"
    $LocalPath = "C:\Upload\Test Upload\My Upload Directory\"
    if ($ManifestFilePath)
    $metadataManifest = (Get-Content ($ManifestFilePath))
    write-host "Manifest file: " $metadataManifest
    else
    write-host "Manifest file not specified for categorising uploaded documents"
    #Check for the LibraryStartFolder parameter to specify a root folder
    if ($PSBoundParameters.ContainsKey('LibraryStartFolder')) {
    $folder = $web.GetFolder($docLibrary.Title + $LibraryStartFolder)
    else
    $folder = $docLibrary.RootFolder
    #Attach to local folder and enumerate through all files
    if($IncludeSubFolders) {
    $files = Get-ChildItem $LocalPath -Recurse
    else
    $files = Get-ChildItem $LocalPath
    $files | ForEach-Object {
    #Check if the object is a folder - if so, create it in doc library
    if ($_.PSIsContainer) {
    if (($IncludeSubFolders) -and (!$FlattenStructure)) {
    #Generate folder path for creation in SharePoint
    #by looking at the parent folder on the local path
    $spFolderPath = ($_.Parent.FullName.Replace($LocalPath,"")).Replace("\","/")
    #Get the folder into which the new folder will be created
    #by adding the folder path generated above, if one existed
    if ($spFolderPath -eq "") {
    $currentFolder = $web.GetFolder($folder.Url)
    else
    $currentFolder = $web.GetFolder($folder.Url + $spFolderPath)
    #Check to see if subfolder already exists
    #and create it if not
    $testFolder = $currentFolder.SubFolders[$_.Name]
    if ($testFolder -eq $null) {
    write-host "`nAdding folder" $_.Name "to" $docLibrary.Title "in" $web.Title "..." -foregroundcolor Green
    $newFolder = $currentFolder.SubFolders.Add($_.Name)
    else
    write-host "`nFolder" $_.Name "already exists in" $docLibrary.Title "and shall not be created" -foregroundcolor Red
    else
    #Generate file path for upload into SharePoint
    if ($FlattenStructure) {
    $spFilePath = ("/" + $_.Name)
    else
    $spFilePath = ($_.FullName.Replace($LocalPath,"")).Replace("\","/")
    $spFullPath = $folder.Url + "/" + $spFilePath
    #Check if the file exists and the overwrite option is selected before adding the file
    if ((!$web.GetFile($spFullPath).Exists) -or ($Overwrite)) {
    #Add file
    write-host "`nCopying" $_.Name "to" $spFullPath.Replace("/" + $_.Name,"") "in" $web.Title "..." -foregroundcolor Green
    $spFile = $folder.Files.Add($spFullPath, $_.OpenRead(), $true)
    #$spFile = $folder.Files.Add($folder.Url + "/" + $file.Name, [System.IO.Stream]$fileStream, $true)
    $spItem = $spFile.Item
    #Walk through manifest XML file and configure column values on the file
    $metadataManifest.Columns.Column | ForEach-Object {
    #Single value text columns
    try
    if (($_.Type -eq "Text") -or
    ($_.Type -eq "Choice") -or
    ($_.Type -eq "Boolean") -or
    ($_.Type -eq "Number") -or
    ($_.Type -eq "Currency")) {
    $columnName = $_.Name
    write-host "Setting value on column"$columnName "..." -foregroundcolor Blue
    $_.Values.Value | ForEach-Object {
    $spItem[$columnName] = $_
    write-host "Value set to"$_
    catch {}
    #Multiple line text column
    try
    catch {}
    #Multiple choice columns
    try
    catch {}
    #Hyperlink columns
    try
    catch {}
    #Single User column
    try
    catch {}
    #Multiple User column
    try
    catch {}
    #Single value Managed Metadata column
    try
    catch {}
    #Multi value Managed Metadata column
    try
    catch {}
    #Update document with new column values
    $spItem.SystemUpdate($false)
    #Check in file to document library (if required)
    #MinorCheckIn=0, MajorCheckIn=1, OverwriteCheckIn=2
    if ($CheckIn) {
    if ($spFile.CheckOutStatus -ne "None") {
    $spFile.CheckIn("File copied from " + $filePath, 1)
    write-host $spfile.Name"checked in"
    #Approve file (if required)
    if ($Approve) {
    if ($spItem.ListItems.List.EnableModeration -eq $true) {
    $spFile.Approve("File automatically approved after copying from " + $filePath)
    if ($spItem["Approval Status"] -eq 0) { write-host $spfile.Name"approved" }
    else
    write-host "`nFile"$_.Name "already exists in" $spFullPath.Replace("/" + $_.Name,"") "and shall not be uploaded" -foregroundcolor Red
    $web.Dispose()
    And here is what the manifest file looks like...
    <?xml version="1.0" encoding="utf-8"?>
    <Columns>
    <Column Name="Column1" Type="Text">
    <Values>
    <Value>First File</Value>
    </Values>
    </Column>
    <Column Name="Column2" Type="Text">
    <Values>
    <Value>12585</Value>
    </Values>
    </Column>
    <Column name="Column3" type="Text">
    <Values>
    <Value>Some Data</Value>
    </Values>
    </Column>
    <Column name="Column4" type="Text">
    <Values>
    <Value>More Data</Value>
    </Values>
    </Column>
    </Columns>
    <Columns>
    <Column Name="Column1" Type="Text">
    <Values>
    <Value>Second File</Value>
    </Values>
    </Column>
    <Column Name="Column2" Type="Text">
    <Values>
    <Value>9876</Value>
    </Values>
    </Column>
    <Column name="Column3" type="Text">
    <Values>
    <Value>Some Data2</Value>
    </Values>
    </Column>
    <Column name="Column4" type="Text">
    <Values>
    <Value>More more Data</Value>
    </Values>
    </Column>
    </Columns>
    I can't figure out what am doing wrong...why my script is not iterating through the manifest file to upload the document along with the metadata. I would really appreciate any help. Thanks

    Hi Spawn,
    Name should not be a problem.. I will probably post you the entire code (I modified it to meet your goals for having multiple column xml nodes as well)
    For the code snippet below:
    a. In powershell all my changes will have ## prefixed comments
    b. in XML I have changed one column name to "Name" to replicate your case and also added a parent node for making the xml well formed.
    and the SharePoint output
    Please see the code below
    $web = Get-SPWeb "http://intranet/sites/test"
    $Library = "My Library"
    $docLibrary = $web.Lists[$Library]
    $ManifestFilePath = "D:\Manifest.xml"
    $LocalPath = "D:\UploadPath\"
    if ($ManifestFilePath)
    ##read the xml file as an xml object
    [xml]$metadataManifest = (Get-Content ($ManifestFilePath))
    write-host "Manifest file: " $metadataManifest
    else
    write-host "Manifest file not specified for categorising uploaded documents"
    #Check for the LibraryStartFolder parameter to specify a root folder
    if ($PSBoundParameters.ContainsKey('LibraryStartFolder')) {
    $folder = $web.GetFolder($docLibrary.Title + $LibraryStartFolder)
    else
    $folder = $docLibrary.RootFolder
    #Attach to local folder and enumerate through all files
    if($IncludeSubFolders) {
    $files = Get-ChildItem $LocalPath -Recurse
    else
    $files = Get-ChildItem $LocalPath
    $counter=0
    $files | ForEach-Object {
    #Check if the object is a folder - if so, create it in doc library
    if ($_.PSIsContainer) {
    if (($IncludeSubFolders) -and (!$FlattenStructure)) {
    #Generate folder path for creation in SharePoint
    #by looking at the parent folder on the local path
    $spFolderPath = ($_.Parent.FullName.Replace($LocalPath,"")).Replace("\","/")
    #Get the folder into which the new folder will be created
    #by adding the folder path generated above, if one existed
    if ($spFolderPath -eq "") {
    $currentFolder = $web.GetFolder($folder.Url)
    else
    $currentFolder = $web.GetFolder($folder.Url + $spFolderPath)
    #Check to see if subfolder already exists
    #and create it if not
    $testFolder = $currentFolder.SubFolders[$_.Name]
    if ($testFolder -eq $null) {
    write-host "`nAdding folder" $_.Name "to" $docLibrary.Title "in" $web.Title "..." -foregroundcolor Green
    $newFolder = $currentFolder.SubFolders.Add($_.Name)
    else
    write-host "`nFolder" $_.Name "already exists in" $docLibrary.Title "and shall not be created" -foregroundcolor Red
    else
    #Generate file path for upload into SharePoint
    if ($FlattenStructure) {
    $spFilePath = ("/" + $_.Name)
    else
    $spFilePath = ($_.FullName.Replace($LocalPath,"")).Replace("\","/")
    $spFullPath = $folder.Url + "/" + $spFilePath
    #Check if the file exists and the overwrite option is selected before adding the file
    if ((!$web.GetFile($spFullPath).Exists) -or ($Overwrite)) {
    #Add file
    write-host "`nCopying" $_.Name "to" $spFullPath.Replace("/" + $_.Name,"") "in" $web.Title "..." -foregroundcolor Green
    $spFile = $folder.Files.Add($spFullPath, $_.OpenRead(), $true)
    #$spFile = $folder.Files.Add($folder.Url + "/" + $file.Name, [System.IO.Stream]$fileStream, $true)
    $spItem = $spFile.Item
    ## ensure we pick the corresponding node in the columns xml (first file, first xml node, second file - second node likewise)
    #Walk through manifest XML file and configure column values on the file
    $metadataManifest.FileData.Columns[$counter].Column | ForEach-Object {
    #Single value text columns
    try
    if (($_.Type -eq "Text") -or
    ($_.Type -eq "Choice") -or
    ($_.Type -eq "Boolean") -or
    ($_.Type -eq "Number") -or
    ($_.Type -eq "Currency")) {
    $columnName = $_.Name
    write-host "Setting value on column"$columnName "..." -foregroundcolor Blue
    $_.Values.Value | ForEach-Object {
    $spItem[$columnName] = $_
    write-host "Value set to"$_
    catch {}
    #Multiple line text column
    try
    catch {}
    #Multiple choice columns
    try
    catch {}
    #Hyperlink columns
    try
    catch {}
    #Single User column
    try
    catch {}
    #Multiple User column
    try
    catch {}
    #Single value Managed Metadata column
    try
    catch {}
    #Multi value Managed Metadata column
    try
    catch {}
    #Update document with new column values
    $spItem.SystemUpdate($false)
    ##increment the counter to read the next xml node
    $counter++
    #Check in file to document library (if required)
    #MinorCheckIn=0, MajorCheckIn=1, OverwriteCheckIn=2
    if ($CheckIn) {
    if ($spFile.CheckOutStatus -ne "None") {
    $spFile.CheckIn("File copied from " + $filePath, 1)
    write-host $spfile.Name"checked in"
    #Approve file (if required)
    if ($Approve) {
    if ($spItem.ListItems.List.EnableModeration -eq $true) {
    $spFile.Approve("File automatically approved after copying from " + $filePath)
    if ($spItem["Approval Status"] -eq 0) { write-host $spfile.Name"approved" }
    else
    write-host "`nFile"$_.Name "already exists in" $spFullPath.Replace("/" + $_.Name,"") "and shall not be uploaded" -foregroundcolor Red
    $web.Dispose()
    and the xml file
    <?xml version="1.0" encoding="utf-8"?>
    <FileData>
    <Columns>
    <Column Name="Name" Type="Text">
    <Values>
    <Value>First File</Value>
    </Values>
    </Column>
    <Column Name="Column2" Type="Text">
    <Values>
    <Value>12585</Value>
    </Values>
    </Column>
    <Column name="Column3" type="Text">
    <Values>
    <Value>Some Data</Value>
    </Values>
    </Column>
    <Column name="Column4" type="Text">
    <Values>
    <Value>More Data</Value>
    </Values>
    </Column>
    </Columns>
    <Columns>
    <Column Name="Name" Type="Text">
    <Values>
    <Value>Second File</Value>
    </Values>
    </Column>
    <Column Name="Column2" Type="Text">
    <Values>
    <Value>12585</Value>
    </Values>
    </Column>
    <Column name="Column3" type="Text">
    <Values>
    <Value>Some Data</Value>
    </Values>
    </Column>
    <Column name="Column4" type="Text">
    <Values>
    <Value>More Data</Value>
    </Values>
    </Column>
    </Columns>
    <Columns>
    <Column Name="Name" Type="Text">
    <Values>
    <Value>Third File</Value>
    </Values>
    </Column>
    <Column Name="Column2" Type="Text">
    <Values>
    <Value>12585</Value>
    </Values>
    </Column>
    <Column name="Column3" type="Text">
    <Values>
    <Value>Some Data</Value>
    </Values>
    </Column>
    <Column name="Column4" type="Text">
    <Values>
    <Value>More Data</Value>
    </Values>
    </Column>
    </Columns>
    <Columns>
    <Column Name="Name" Type="Text">
    <Values>
    <Value>Fourth File</Value>
    </Values>
    </Column>
    <Column Name="Column2" Type="Text">
    <Values>
    <Value>12585</Value>
    </Values>
    </Column>
    <Column name="Column3" type="Text">
    <Values>
    <Value>Some Data</Value>
    </Values>
    </Column>
    <Column name="Column4" type="Text">
    <Values>
    <Value>More Data</Value>
    </Values>
    </Column>
    </Columns>
    <Columns>
    <Column Name="Name" Type="Text">
    <Values>
    <Value>Fifth File</Value>
    </Values>
    </Column>
    <Column Name="Column2" Type="Text">
    <Values>
    <Value>12585</Value>
    </Values>
    </Column>
    <Column name="Column3" type="Text">
    <Values>
    <Value>Some Data</Value>
    </Values>
    </Column>
    <Column name="Column4" type="Text">
    <Values>
    <Value>More Data</Value>
    </Values>
    </Column>
    </Columns>
    </FileData>
    Thanks and Regards,
    Partha
    AvePoint

  • Using xsgl:insert-request to insert non-English character data from HTML form

    I tried to insert a text written in French and pasted into an HTML form into my database following the recipe from the XSQL release notes.
    The table:
    create table content_object (
    id number(9) constraint pk_content_object primary key,
    author number(9),
    title varchar2(256),
    abstract varchar2(1024),
    object_type_id number(9),
    content_meat clob,
    XML file the form is posted to:
    <?xml version="1.0"?>
    <xsql:insert-request connection="demo"
    xmlns:xsql="urn:oracle-xsql"
    table="content_object"
    transform="article_form_to_content_object.xsl"/>
    article_form_to_content_object.xsl:
    <?xml version = '1.0'?>
    <ROWSET xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xsl:version="1.0">
    <xsl:for-each select="request/parameters">
    <ROW>
    <TITLE><xsl:value-of select="title_field"/></TITLE>
    <ABSTRACT><xsl:value-of select="abstract_field"/></ABSTRACT>
    <CONTENT_MEAT><xsl:value-of select="content_field"/></CONTENT_MEAT>
    </ROW>
    </xsl:for-each>
    </ROWSET>
    The result was:
    <ROW num="2">
    <ID>6</ID>
    <TITLE>Le go</TITLE>
    <ABSTRACT>Vin bouchonn</ABSTRACT>
    <CONTENT_MEAT>Des conditions de conservation au tant d</CONTENT_MEAT>
    </ROW>
    All strings were cropped at the point where the first accented character appeared.
    Any idea why this is happening? With English texts it works just fine.
    Maciej

    Another user hit this problem this week. I debugged it and posted the reply in the discussion thread:
    http://technet.oracle.com:89/ubb/Forum11/HTML/002799.html
    It's a JDK bug in character set conversion that has a simple workaround, just indicate the ISO-8859-1 encoding on your XSQL page. See the end of this other thread for details.

  • Uploading files using a separate HTML editor

    Because the Verizon website builder is not consistent, I am using a separate HTML editor for uploading files to my personal webpage. However, sofar I am unable to get information from Verizon as to what folder I should upload the files to, in order to view them through my browser. Anyone went through the same experience?
    Solved!
    Go to Solution.

    I point to http://www22.verizon.com/ResidentialHelp/HighSpeed/Email/Setup+And+Use/QuestionsOne/86782.htm?caseRe...
    where they cleary have the FTP Server Settings.
    If you are the original poster (OP) and your issue is solved, please remember to click the "Solution?" button so that others can more easily find it. If anyone has been helpful to you, please show your appreciation by clicking the "Kudos" button.

Maybe you are looking for