File Upload using Flex/ColdFusion.  2044 error

I am looking for a little more clarity around the file upload using Flex and Cold Fusion.  When I run this using my server I get Error #2044: Unhandled IOErrorEvent:. text=Error #2038: File I/O Error.
I did create a regular cfform and had it use my ColdFusion upload form and that worked fine, so I feel good about the upload form. I am starting to think there is a permission error with the Flash Player writing to the folder.  When this is ran, it will show the file being 100% loaded but the complete event is never triggered.  I put alerts to see where it hits and 100 does show at the same time as my error message.  The complete alert never shows.  I also put an alert in my cfm page and it never reaches that page to hit it.  Whether I use an absolute URL or relative path. I have also tried the urlrequestmethod.post and nothing changed.  Thanks in advance.  BTW.  I am using Flex 3.
This is my mxml file
<?xml version="1.0" encoding="utf-8"?>
<mx:Application 
xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:example="com.example.*" horizontalAlign="center" viewSourceURL="srcview/index.html">
<mx:Script>
<![CDATA[
import com.example.FileDownload 
import mx.controls.Label 
import com.example.FileUpload]]>
</mx:Script>
<mx:Label id="title" text="File I/O Example" fontSize="24" fontStyle="bold" />
<mx:Text id="subtitle" text="From Programming ActionScript 3.0, Chapter 22: Networking and communication" width="100%" textAlign="center" fontSize="12" /><example:FileDownload 
id="fileDownload" creationComplete="fileDownload.init(downloadProgress, cancelDownload);" />
<example:FileUpload id="fileUpload" creationComplete="fileUpload.init(uploadProgress, cancelUpload);" />
<mx:HBox>
<mx:Panel title="Upload File" paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10">
<mx:ProgressBar id="uploadProgress" label="" mode="manual" />
<mx:ControlBar horizontalAlign="right">
<mx:Button id="startUpload" label="Upload..." click="fileUpload.startUpload();" />
<mx:Button id="cancelUpload" label="Cancel" click="fileUpload.cancelUpload();" enabled="false" />
</mx:ControlBar>
</mx:Panel>
<mx:Panel title="Download File" paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10">
<mx:ProgressBar id="downloadProgress" label="" mode="manual" />
<mx:ControlBar horizontalAlign="right">
<mx:Button id="startDownload" label="Download..." click="fileDownload.startDownload();" />
<mx:Button id="cancelDownload" label="Cancel" click="fileDownload.cancelDownload();" enabled="false" />
</mx:ControlBar>
</mx:Panel>
</mx:HBox></mx:Application>
here is my coldfusion upload script
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<script>alert('hello')</script>
<cfset currentPath = getCurrentTemplatePath()>
<cfset currentDirectory = getDirectoryFromPath(currentPath)>
<cfoutput>This directory is #currentDirectory#</cfoutput>
<cffile action="UPLOAD" filefield="Filefield" destination="#currentDirectory#" nameconflict="OVERWRITE"/>
</body>
</html>
here is the package
package  
com.example { import flash.events.*; 
import flash.net.FileReference; 
import flash.net.URLRequest; 
import flash.net.URLRequestMethod; 
import mx.controls.Button; 
import mx.controls.ProgressBar; 
import mx.core.UIComponent; 
import mx.controls.Alert; 
public class FileUpload extends UIComponent { 
// Hard-code the URL of the remote upload script. 
private const UPLOAD_URL:String = "upload_script.cfm"; 
private var fr:FileReference; 
// Define reference to the upload ProgressBar component. 
private var pb:ProgressBar; 
// Define reference to the "Cancel" button which will immediately stop the upload in progress. 
private var btn:Button; 
public function FileUpload() {}
/*** Set references to the components, and add listeners for the SELECT,
* OPEN, PROGRESS, and COMPLETE events.
 public function init(pb:ProgressBar, btn:Button):void { 
// Set up the references to the progress bar and cancel button, which are passed from the calling script. 
this.pb = pb; 
this.btn = btn; 
fr =
new FileReference();fr.addEventListener(Event.SELECT, selectHandler);
fr.addEventListener(Event.OPEN, openHandler);
fr.addEventListener(ProgressEvent.PROGRESS, progressHandler);
// fr.addEventListener(Event.COMPLETE, completeHandler); 
/*** Immediately cancel the upload in progress and disable the cancel button.
 public function cancelUpload():void {fr.cancel();
pb.label =
"UPLOAD CANCELLED";btn.enabled =
false;}
/*** Launch the browse dialog box which allows the user to select a file to upload to the server.
 public function startUpload():void {fr.browse();
/*** Begin uploading the file specified in the UPLOAD_URL constant.
 private function selectHandler(event:Event):void { 
var request:URLRequest = new URLRequest(UPLOAD_URL); 
/* request.url = UPLOAD_URL*/request.method = URLRequestMethod.POST;
 try  
{fr.upload(request);
}catch (error:Error){
trace  
("error uploading")}
 /*** When the OPEN event has dispatched, change the progress bar's label
* and enable the "Cancel" button, which allows the user to abort the
* upload operation.
 private function openHandler(event:Event):void {pb.label =
"UPLOADING";btn.enabled =
true;}
/*** While the file is uploading, update the progress bar's status and label.
 private function progressHandler(event:ProgressEvent):void {pb.label =
"UPLOADING %3%%";pb.setProgress(event.bytesLoaded, event.bytesTotal);
if(event.bytesLoaded==event.bytesTotal){ 
trace(Event.COMPLETE)Alert.show(
"100")}
/*** Once the upload has completed, change the progress bar's label and
* disable the "Cancel" button since the upload is already completed.
 private function completeHandler(event:Event):void {Alert.show(
"in function")pb.label =
"UPLOADING COMPLETE";pb.setProgress(0, 100);
btn.enabled =
false;}

Presumably you need to add a result handler to your request.

Similar Messages

  • Cannot delete file - tried everything - file in use by Windows Explorer error

    Hi - I have tried now for 2-3 hours trying to delete an .mkv file from my "Downloads" folder
    It says the file is in use by Windows Explorer and cannot be deleted
    I have tried deleting it using Del command prompt as me and as Administrator (I am the Admnistrator, there are no other users) - no luck
    I have tried Safe Boot and then deleting - no luck
    I have tried rebooting many times and then deleting - no luck
    Any ideas? It's driving me nuts

    hi to all who have this bug- "file in use by Windows Explorer error"
    this is the only way that it works:
    1.type cmd in search box
    2.go to the drive and the directory the file is in ,for example:
    after you type cmd you have a black screen with c:\user\
    type in the drive the file is in and hit enter example - d: than hit enter
    than you should see d:\>
    now click the directory the problem file is in ,for example i will call the directory "movies"  type in this-   cd movies
    now you will see this d:\movies>
    to delete the file type this:  del filename.mkv (dont forget the .mkv or any other file extension) don't hit enter yet, first open task manager (cntrl+shift+esc) go to process tab than right click on explorer.exe choose and click on end process
    now your desktop should disappear. get back to the "cmd" window and hit enter.
    now the file is deleted. now go back to the task manager and click on "file" on the upper left corner then on new task then type in "explorer.exe"
    and you are done
    please note that the file name you choose to delete cant be with spaces between the letters .if so you will need to change it in the same way in the cmd window only the comand will be instead of "del filename.mkv"(for example) after you are in the
    right drive and directory:
    rename "test space.mkv" testspace.mkv
    hope i helped
    this is the only way it workes
    Instead of running a CMD prompt and typing everything, just start up Winrar or Winzip, kill Explorer, then delete problem MKV files to your hearts content within Winrar or Winzip.
    Winrar and Winzip will navigate your folders as well.
    After you are done, create a new Explorer task.
    or.....   if you need to rename MKV files, just rename them within Winrar/Winzip with Explorer not running.
    I change the MKV extension to AVI (in Winrar with Explorer killed) in order to avoid Explorer issues, if I ever want to move the files in the future without needing to kill Explorer all the time to do so .
    Using WinRAR works for me. Using the cmd function becomes complicated when I cannot rename my file with the rename command".

  • I am getting a error IO when trying to upload multiple images within wordpress using the flash uploader. I do not get the error when uploading using explorer. The error only appears if I try uploading using firefox....any ideas?

    I am getting a error IO when trying to upload multiple images within wordpress using the flash uploader. I do not get the error when uploading using explorer. The error only appears if I try uploading using firefox....any ideas?

    Logged the call with SAP who directed me to 'Define settings for attachments' in IMG and setting the 'Deactivate Java Applet' & 'Deactivate Attachment versioning' checkboxes - problem solved.

  • File uploads using servlets to oracle8i database

    Hi,
    Help please, How I can a File Upload using BLOB's into the oracle database, any sugestions...
    Thanks
    Moacyr
    [email protected]

    Try the jason hunter book Java Servlet Programming for a very good description or the web site hosted by o'reilly
    www.servlets.com
    Has a very neat java class for decoding multipart mime encoded files (the upload stream from the browser). Seems to accomodate most of the differing browsers intretation of the standard.
    Note to Oracle: This should really be handled by the servlet engine as an Oracle extension. Where the servlet engine strips the mime encoding out before the servlet is called placing the decoded file in an associated extension call. ie: cast the request to an Oracle request object which has file uploaded method.

  • File uploads using jQuery with jquery.fileupload.js fails in Firefox over SSL

    Please see the link below where I originally posted the question.
    http://stackoverflow.com/questions/27792614/file-uploads-using-jquery-with-jquery-fileupload-js-fails-in-firefox-over-ssl

    Thanks. In my estimation that is exactly the issue. But that doesn't help with a resolution.
    The actual file size: 945,991 bytes
    If Firefox is miscalculating the length (in Safari/Chrome 945991 and 946241 in Firefox), then Firefox is reporting erroneously and should be raised as a bug in Firefox, would you agree?

  • File uploads from Flex

    How do I enable CF to allow file uploads from Flex?

    You will need to set the accept attribute of the cffile tag
    to allow the mime type application/octet-stream.

  • URGENT.........File Upload using Servlets and jsp

    I am a new servlet programmer.......
    iam using tomcat server......
    can any one pls help in writing code for file upload using servlets and jsp without using multipart class or any other class like that....
    Please URGENT..

    Slow down! "Urgent" is from your perspective alone. I, myself, am not troubled or worried in the least.
    hi ugniss
    thanks for ur reply....sorry i was not
    y i was not asked not to use multipart class or any
    other class like that...is there any other
    possibility to do file uploading from jsp to
    servlet...
    Just as an aside, a JSP is a Servlet. But even if I move beyond that, the question does not make sense. If you want a "JSP to upload to a Servlet", then simply do so in memory. You are still (likely) within the same scope of a given request. However, if instead you are referring to a JSP that is displayed on a browser, then really you are talking about HTML, which is what the browser will receive. And since you are now talking about a browser, your only real, viable option is a multi-part file upload. So, it is either server or it is browser. And either way, the question leads to very established options, as outlined above.
    the main concept is.. in the browser the user selects
    a particular file and clicks the button upload..after
    clicking upload the jsp should sent the file to the
    servlet in streams...there the servlet gets in and
    saves in a server location........this is wat i hav
    to do...
    Okay. So, after reading my previous (redundant) paragraph, we have arrived at the crux of the issue. You have a JSP that will be output as HTML to a client (browser) which you want to upload content to your server (handled by a Servlet). So, you are now stuck again with multi-part. The requirement to not use multi-part is non-sensical. You can overcome it, say, if you write your own applet or standalone Swing client. However, if your users are invoking this functionality from a browser, you are limited by the options that W3C has provided you. Use multi-part.
    is there aby possibilty to do this.....can any one
    pls help....Take the advice to download and review Jakarta Commons FileUpload. Inform your management that their requirement makes no technical sense. Research on your own. There are dozens of examples (and tutorials) on file upload using multi-part. Embrace it. Live it. Love it.
    - Saish

  • HTML File Upload - using DAD - Error

    I have set up my document table, the document upload package is in there, but my HTML for the file upload is not working correctly:
    DAD info
    DAD Name: /pls/portal
    Document Table: dw_target.documents
    Document Access Procedure: document_api.download
    here is the upload HTML:
    <html>
    <head>
    <title>test upload</title>
    </head>
    <body>
    <form enctype="multipart/form-data" action="http://MYURL:7777/portal/pls/portal/dw_target.document_api.download" method="post">
    File to upload: <input type="file" name="file"><br>
    <input type="submit" value="Upload">
    </form>
    </body>
    </html>
    But i get this error when i try to upload a doc:
    The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.
    anyone have any insight on how to get the file upload to work (specifically how to configure the HTML to correctly use the upload process?
    using Oracle App Server 10g
    jason

    Pschar,
    What is "dw_target.documents"?
    Joel

  • Error in File uploading using jsp

    I am tring to upload files to a mysql database using jsp.I have used BLOB type to store files.Iam using the JDBC driver mysql-connector-java-2.0-14-bin to connect the database with the jsp API.My problem is when i try to transfer a file of size which is less than the possible capacity through blob ,which is 1048576 bytes ( for example when a file of size 916KB is attempted to transfer) the following error is being generated.
    java.lang.IllegalArgumentException: Packet is larger than max_allowed_packet from server configuration of 1048576 bytes
         at com.mysql.jdbc.Buffer.ensureCapacity(Unknown Source)
         at com.mysql.jdbc.Buffer.writeBytesNoNull(Unknown Source)
         at com.mysql.jdbc.PreparedStatement.executeUpdate(Unknown Source)
         at com.mysql.jdbc.PreparedStatement.executeUpdate(Unknown Source)
         at org.apache.jsp.file3$jsp._jspService(file3$jsp.java:110)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:475)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
         at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
         at java.lang.Thread.run(Thread.java:484)
    java.lang.IllegalArgumentException: Packet is larger than max_allowed_packet from server configuration of 1048576 bytes
         at com.mysql.jdbc.Buffer.ensureCapacity(Unknown Source)
         at com.mysql.jdbc.Buffer.writeBytesNoNull(Unknown Source)
         at com.mysql.jdbc.PreparedStatement.executeUpdate(Unknown Source)
         at com.mysql.jdbc.PreparedStatement.executeUpdate(Unknown Source)
         at org.apache.jsp.file3$jsp._jspService(file3$jsp.java:110)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:475)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
         at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
         at java.lang.Thread.run(Thread.java:484)
    My uploading code in jsp is as follows.
         <% try{
              Class.forName("org.gjt.mm.mysql.Driver").newInstance();
              Connection dbCon = DriverManager.getConnection("jdbc:mysql:///uoc");
              out.println("Connection done !");
              Statement stmt = dbCon.createStatement();
              out.println("Statement Created !");
    ResultSet rs = stmt.executeQuery("SELECT * FROM blob_test)
    stmt.close();
    dbCon.close();
    out.println("<br><br> <b>Data Successfully selected !<b>");
    } //try
    catch(SQLException e){
         out.println(" <br> ");
         out.println("Sorry ! problem in selecting a data "+e.toString());
         out.println(" <br> ");
                   e.printStackTrace();
    %>
    Please help .I thank You in advance for any help .

    Have you tried increasing the BLOB field greater than 1048576 or using a smaller file of say 1 or 2k as a test? There is no guarantee that the database will store the file with exactly the same size as the file on the filesystem, so the file might be more than 916k in the database.
    Using BLOBs is a great way to destroy the performance of your database by the way :)

  • Error in image file upload using dreamweaver

    Greeting to you all!
    Please I need you PRO help. My case seem similar to some of the ones I have seen but my code is completely different.
    I wrote this code below using PHP in Dreamweaver and its used to upload images to MySQl database. Now when I upload about 6 images, it shows File Uploaded Successfully. But if I try to upload any thing below 6 images, it will refuse to upload and will echo Upload Failed.
    <?php
    if(isset($_POST['submit']))
              $projid=$_POST['projid'];
              $projname=$_POST['projname'];
              $name=basename($_FILES['file_upload']['name']);
              $t_name=$_FILES['file_upload']['tmp_name'];
              $dir='upload';
              if(move_uploaded_file($t_name,$dir."/".$name))
              $nameone=basename($_FILES['file_uploadone']['name']);
              $t_name=$_FILES['file_uploadone']['tmp_name'];
              $dir='upload1';
              if(move_uploaded_file($t_name,$dir."/".$name))
              $nametwo=basename($_FILES['file_uploadtwo']['name']);
              $t_name=$_FILES['file_uploadtwo']['tmp_name'];
              $dir='upload2';
              if(move_uploaded_file($t_name,$dir."/".$name))
              $namethree=basename($_FILES['file_uploadthree']['name']);
              $t_name=$_FILES['file_uploadthree']['tmp_name'];
              $dir='upload3';
              if(move_uploaded_file($t_name,$dir."/".$name))
              $namefour=basename($_FILES['file_uploadfour']['name']);
              $t_name=$_FILES['file_uploadfour']['tmp_name'];
              $dir='upload4';
              if(move_uploaded_file($t_name,$dir."/".$name))
              $namefive=basename($_FILES['file_uploadfive']['name']);
              $t_name=$_FILES['file_uploadfive']['tmp_name'];
              $dir='upload5';
              if(move_uploaded_file($t_name,$dir."/".$name))
                        mysql_select_db ($database_ProjMonEva,$ProjMonEva);
                        $qur="insert into tbl_images (imageid, projid, projname, name, path, nameone, pathone, nametwo, pathtwo, namethree, paththree, namefour, pathfour, namefive, pathfive) values ('','$projid','$projname','$name','upload/$name','$nameone','upload/$nameone','$nametwo', 'upload/$nametwo','$namethree','upload/$namethree','$namefour','upload/$namefour','$namefi ve','upload/$namefive')";
                        $res=mysql_query($qur,$ProjMonEva);
                        echo 'File uploaded successful';
              else
                        echo 'upload failed!';
    ?>
    I see the problem to come from the echo but I am stock and dont know how to correct it. Can any one please help me.
    Thank you in advance Mike

    Hi Bregent,
    I have been able to resolve the issue. I modified the code this way: This I believe will help those having the same issues.
    These is how I was able to achieve it.
    1. I divided the code into two parts called addnew.php and addnewproject.php.
    The addnewproject.php as seen below will call the addnew.php when the submit button on addnewproject.php is clicked
    <form action="addnew.php" method="POST" id="Add New Project" enctype="multipart/form-data">
          <div align="center">
            <table width="600" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td id="formcells4"><strong id="subheaders">Core Details</strong></td>
                <td></td>
              </tr>
              <tr>
                <td id="dates">*Code (Eg. 2104/12/AB23):<br />
                  <label for="projcode"></label>
                  <span id="sprytextfield1">
                  <input type="text" name="projcode" id="projcode2" />
                <span class="textfieldRequiredMsg">A value is required.</span></span><br /></td>
                <td></td>
              </tr>
              <tr>
                <td colspan="2" id="dates">Project Name:
                  <label for="projname3"></label>
                  <span id="sprytextfield2">
                  <input type="text" name="projname" id="projname3" />
                  <span class="textfieldRequiredMsg">A value is required.</span></span></td>
              </tr>
              <tr>
                <td colspan="2" id="dates">Project Description:<span id="description"><br />
                  <label for="projdesc"></label>
                  <span id="txt_projdesc">
                    <textarea name="projdesc" id="projdesc" cols="70" rows="8"></textarea>
                    <span class="textareaRequiredMsg">A value is required.</span></span></span></td>
              </tr>
              <tr>
                <td id="formcells"><p id="dates">*Date Entered: <em>YYYY/MM/DD</em><span id="year">
                  <label for="projappdate"><br />
                  </label>
                  <span id="txt_dateproapp">
                    <input type="text" name="projappdate" id="projappdate" />
                    <span class="textfieldRequiredMsg">A value is required.</span></span></span></p></td>
                <td id="formcells"><p id="dates">*Project LGA:<span id="txt_projlga">
                  <label for="projlga"><br />
                  </label>
                  <span id="txt_lga">
                    <select name="projlga" id="projlga">
                      <option value="1">.... Select from list ....</option>
                      <?php
    do { 
    ?>
                      <option value="<?php echo $row_rsLGA['lga']?>"><?php echo $row_rsLGA['lga']?></option>
                      <?php
    } while ($row_rsLGA = mysql_fetch_assoc($rsLGA));
      $rows = mysql_num_rows($rsLGA);
      if($rows > 0) {
          mysql_data_seek($rsLGA, 0);
                $row_rsLGA = mysql_fetch_assoc($rsLGA);
    ?>
                    </select>
                <span class="selectRequiredMsg">Please select an item.</span></span></span></p></td>
              </tr>
              <tr>
                <td id="formcells6"><p id="dates">*Project Community:<span id="txt_ojcommunity">
                  <label for="projcommunity"><br />
                  </label>
                  <select name="projcommunity" id="projcommunity">
                    <option value="1">.... Select from list ....</option>
                    <?php
    do { 
    ?>
                    <option value="<?php echo $row_rsCommunity['community']?>"><?php echo $row_rsCommunity['community']?></option>
                    <?php
    } while ($row_rsCommunity = mysql_fetch_assoc($rsCommunity));
      $rows = mysql_num_rows($rsCommunity);
      if($rows > 0) {
          mysql_data_seek($rsCommunity, 0);
                $row_rsCommunity = mysql_fetch_assoc($rsCommunity);
    ?>
                  </select>
                </span></p></td>
                <td id="formcells6"><p id="dates">*Project State:<span id="txt_projstate"><br />
                  <select name="projstate" id="projstate">
                    <option value="1">.... Select from list ....</option>
                    <?php
    do { 
    ?>
                    <option value="<?php echo $row_rsState['state']?>"><?php echo $row_rsState['state']?></option>
                    <?php
    } while ($row_rsState = mysql_fetch_assoc($rsState));
      $rows = mysql_num_rows($rsState);
      if($rows > 0) {
          mysql_data_seek($rsState, 0);
                $row_rsState = mysql_fetch_assoc($rsState);
    ?>
                  </select>
                </span></p></td>
              </tr>
              <tr>
                <td height="63" id="formcells8"><p id="dates">Project Cost:<span id="txt_projcost"><br />
                  <label for="projcost"></label>
                  <span id="txt_projectcost">
                    <input name="projcost" type="text" id="projcost" />
                    <span class="textfieldRequiredMsg">A value is required.</span></span></span></p></td>
                <td id="formcells"><p id="dates">*Project Type:<span id="txt_projtype"><br />
                  <label for="projtype"></label>
                  <select name="projtype" id="projtype">
                    <option value="1">.... Select from list ....</option>
                    <?php
    do { 
    ?>
                    <option value="<?php echo $row_rsType['projtypelist']?>"><?php echo $row_rsType['projtypelist']?></option>
                    <?php
    } while ($row_rsType = mysql_fetch_assoc($rsType));
      $rows = mysql_num_rows($rsType);
      if($rows > 0) {
          mysql_data_seek($rsType, 0);
                $row_rsType = mysql_fetch_assoc($rsType);
    ?>
                  </select>
                </span></p></td>
              </tr>
              <tr>
                <td colspan="2" id="formcells2"><p id="dates">Project Baseline Data:<span id="sprytextarea2"><br />
                  <label for="projbaselinedata"></label>
                  <textarea name="projbaselinedata" id="projbaselinedata" cols="70" rows="8"></textarea>
                </span></p></td>
              </tr>
              <tr>
                <td colspan="2" id="formcells3"><p id="dates">Expected Outcome Of Project:<span id="sprytextarea3"><br />
                  <label for="Projexpoutcome"></label>
                  <textarea name="Projexpoutcome" id="Projexpoutcome" cols="70" rows="8"></textarea>
                </span></p></td>
              </tr>
            </table>
            <table width="600" border="0" cellpadding="0" cellspacing="0" id="teamtable">
              <tr>
                <td colspan="2"><strong id="subheaders">Beneficiaries</strong></td>
              </tr>
              <tr>
                <td width="241"><p>Adult Men Beneficiaries: <span id="txt_adultmen">
                  <label for="adultmen"><br />
                  </label>
                  <input name="adultmen" type="text" id="adultmen" />
                </span></p></td>
                <td width="259"><p>Adult Female Beneficiaries:<span id="txt_adultfem"><br />
                  <label for="adultfem"></label>
                  <input name="adultfem" type="text" id="adultfem" />
                </span></p></td>
              </tr>
              <tr>
                <td><p>Adult Children Beneficiaries:<span id="txt_totalchildren"><br />
                  <label for="children"></label>
                  <input name="totalchildren" type="text" id="totalchildren" />
                </span></p></td>
                <td><p>Total Beneficiaries:<span id="sprytextfield4"><br />
                  <label for="totalben"></label>
                  <input name="totalben" type="text" id="totalben" readonly="readonly" />
                </span></p></td>
              </tr>
              <tr>
                <td><p> </p></td>
                <td><p> </p></td>
              </tr>
              <tr>
                <td><strong id="subheaders">Project Team</strong></td>
                <td><p> </p></td>
              </tr>
              <tr>
                <td><p>*Project Team Leader:<span id="spryselect1"><br />
                  <label for="projteamlead"></label>
                  <select name="projteamlead" id="projteamlead">
                    <option value="1">.... Select from list ....</option>
                    <?php
    do { 
    ?>
                    <option value="<?php echo $row_rsProjectTeam['fullname']?>"><?php echo $row_rsProjectTeam['fullname']?></option>
                    <?php
    } while ($row_rsProjectTeam = mysql_fetch_assoc($rsProjectTeam));
      $rows = mysql_num_rows($rsProjectTeam);
      if($rows > 0) {
          mysql_data_seek($rsProjectTeam, 0);
                $row_rsProjectTeam = mysql_fetch_assoc($rsProjectTeam);
    ?>
                  </select>
                </span></p></td>
                <td><p>*Deputy Team Leader:<span id="spryselect2"><br />
                  <label for="projteamlead"></label>
                  <select name="projdepteamlead" id="projdepteamlead">
                    <option value="1">.... Select from list ....</option>
                    <?php
    do { 
    ?>
                    <option value="<?php echo $row_rsProjectTeam['fullname']?>"><?php echo $row_rsProjectTeam['fullname']?></option>
                    <?php
    } while ($row_rsProjectTeam = mysql_fetch_assoc($rsProjectTeam));
      $rows = mysql_num_rows($rsProjectTeam);
      if($rows > 0) {
          mysql_data_seek($rsProjectTeam, 0);
                $row_rsProjectTeam = mysql_fetch_assoc($rsProjectTeam);
    ?>
                  </select>
                </span></p></td>
              </tr>
              <tr>
                <td><p>*Project Officer:<span id="spryselect3"><br />
                  <label for="projteamlead"></label>
                  <select name="projofficer" id="projofficer">
                    <option value="1">.... Select from list ....</option>
                    <?php
    do { 
    ?>
                    <option value="<?php echo $row_rsProjectTeam['fullname']?>"><?php echo $row_rsProjectTeam['fullname']?></option>
                    <?php
    } while ($row_rsProjectTeam = mysql_fetch_assoc($rsProjectTeam));
      $rows = mysql_num_rows($rsProjectTeam);
      if($rows > 0) {
          mysql_data_seek($rsProjectTeam, 0);
                $row_rsProjectTeam = mysql_fetch_assoc($rsProjectTeam);
    ?>
                  </select>
                </span></p></td>
                <td><p>*Liason Officer:<span id="spryselect4"><br />
                  <label for="projteamlead"></label>
                  <select name="projliasonofficer" id="projliasonofficer">
                    <option value="1">.... Select from list ....</option>
                    <?php
    do { 
    ?>
                    <option value="<?php echo $row_rsProjectTeam['fullname']?>"><?php echo $row_rsProjectTeam['fullname']?></option>
                    <?php
    } while ($row_rsProjectTeam = mysql_fetch_assoc($rsProjectTeam));
      $rows = mysql_num_rows($rsProjectTeam);
      if($rows > 0) {
          mysql_data_seek($rsProjectTeam, 0);
                $row_rsProjectTeam = mysql_fetch_assoc($rsProjectTeam);
    ?>
                  </select>
                </span></p></td>
              </tr>
            </table>
            <table width="600" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="300" id="moredetails2"> </td>
                <td width="300"> </td>
              </tr>
              <tr id="moredetails">
                <td width="300" id="moredetails"><strong id="subheaders">Meeting Dates</strong></td>
                <td width="300"><strong id="subheaders">Other Dates</strong></td>
              </tr>
              <tr id="formrows">
                <td width="300" id="formrows"><p id="dates">*1st  Meeting Date: <em>YYYY/MM/DD</em><span id="txt_projmeeting1"><br />
                  <input type="text" name="projmeeting1" id="projmeeting1" />
                </span></p></td>
                <td width="300" id="formrows"><p id="dates">*Project Start Date: <em id="formcells">YYYY/MM/DD</em><span id="txt_projstartdate">
                  <label for="projstartdate"></label>
                  <input type="text" name="projstartdate" id="projstartdate" />
                  </span>
                  <label for="projstartdate"></label>
                </p></td>
              </tr>
              <tr>
                <td width="300" id="formrows"><p id="dates">*2nd  Meeting Date: <em>YYYY/MM/DD</em><span id="txt_projmeeting2"><br />
                  <input type="text" name="projmeeting2" id="projmeeting2" />
                  </span>
                  <label for="projteam2"></label>
                  <label for="projmeeting2"></label>
                </p></td>
                <td width="300" id="formrows"><p id="dates">*Project End Date: <em>YYYY/MM/DD</em><span id="txt_projenddate"><br />
                  <label for="projenddate2"></label>
                  <input type="text" name="projenddate" id="projenddate" />
                </span></p></td>
              </tr>
              <tr>
                <td width="300" id="formrows"><p id="dates">*3rd Meeting Date: <em>YYYY/MM/DD</em><span id="txt_projmeeting3"><br />
                  <input type="text" name="projmeeting3" id="projmeeting3" />
                </span></p></td>
                <td width="300" id="formrows"><p id="dates">*MoU Signing Date: <em id="formcells">YYYY/MM/DD</em><span id="txt_projmousigndate"><br />
                  <label for="projmousigndate"></label>
                  <input type="text" name="projmousigndate" id="projmousigndate" />
                </span></p></td>
              </tr>
              <tr>
                <td colspan="2" id="formrows2"><div align="center" id="notice"><img src="images/notice.jpg" width="501" height="73" /></div></td>
              </tr>
            </table>
          </div>
          <p align="center"></p>
          <p align="center" id="text">
            <input type="file" name="file_upload" />
            <input type="file" name="file_uploadone" />
            <input type="file" name="file_uploadtwo" />
          </p>
          <p align="center" id="text">
            <input type="file" name="file_uploadthree" />
            <input type="file" name="file_uploadfour" />
            <input type="file" name="file_uploadfive" />
          </p>
          <p align="center">
            <input type="submit" name="submit" value="Save &amp; Submit"/>
          </p>
        </form>
    The addnew.php will now execute and add the data and image file names and path to MySQL database and upload the images to their various locations. it will also check the image file size be sure its not more than 100kb and must really be an iamge with format .jpg, .png and .gif.
    <?php
    if(isset($_POST['submit']))
              $projcode=$_POST['projcode'];
              $projname=$_POST['projname'];
              $projname=$_POST['projname'];
              $projdesc=$_POST['projdesc'];
              $projappdate=$_POST['projappdate'];
              $projcommunity=$_POST['projcommunity'];
              $projlga=$_POST['projlga'];
              $projstate=$_POST['projstate'];
              $projcost=$_POST['projcost'];
              $projtype=$_POST['projtype'];
              $projbaselinedata=$_POST['projbaselinedata'];
              $Projexpoutcome=$_POST['Projexpoutcome'];
              $adultmen=$_POST['adultmen'];
              $adultfem=$_POST['adultfem'];
              $totalchildren=$_POST['totalchildren'];
              $totalben=$_POST['totalben'];
              $projteamlead=$_POST['projteamlead'];
              $projdepteamlead=$_POST['projdepteamlead'];
              $projofficer=$_POST['projofficer'];
              $projliasonofficer=$_POST['projliasonofficer'];
              $projmeeting1=$_POST['projmeeting1'];
              $projmeeting2=$_POST['projmeeting2'];
              $projmeeting3=$_POST['projmeeting3'];
              $projmousigndate=$_POST['projmousigndate'];
              $projstartdate=$_POST['projstartdate'];
              $projenddate=$_POST['projenddate'];
              $name=basename($_FILES['file_upload']['name']);
              $t_name=$_FILES['file_upload']['tmp_name'];
              $dir='imageone';
              // Validate uploaded image file
              if ( !preg_match( '/gif|png|jpeg/', $_FILES['file_upload']['type']) ) {
                           die('<p>Only browser compatible images allowed</p></body></html>');
              } else if ( $_FILES['file_upload']['size'] > 100000 )
                           die('<p>Sorry file too large</p></body></html>');
              if(move_uploaded_file($t_name,$dir."/".$name))
                        echo 'File 1 uploaded successfully....!';
              else
                        echo 'File 1 upload failed or was not submitted....!  ';
              $nameone=basename($_FILES['file_uploadone']['name']);
              $t_name=$_FILES['file_uploadone']['tmp_name'];
              $dir='imagetwo';
              // Validate uploaded image file
              if ( !preg_match( '/gif|png|jpeg/', $_FILES['file_uploadone']['type']) ) {
                           die('<p>Only browser compatible images allowed</p></body></html>');
              } else if ( $_FILES['file_uploadone']['size'] > 100000 )
                           die('<p>Sorry file too large</p></body></html>');
              if(move_uploaded_file($t_name,$dir."/".$nameone))
                        echo 'File 2 was uploaded successfully....!';
              else
                        echo '...File 2 upload failed or was not submitted!  ';
              $nametwo=basename($_FILES['file_uploadtwo']['name']);
              $t_name=$_FILES['file_uploadtwo']['tmp_name'];
              $dir='imagethree';
              // Validate uploaded image file
              if ( !preg_match( '/gif|png|jpeg/', $_FILES['file_uploadtwo']['type']) ) {
                           die('<p>Only browser compatible images allowed</p></body></html>');
              } else if ( $_FILES['file_uploadtwo']['size'] > 100000 )
                           die('<p>Sorry file too large</p></body></html>');
              if(move_uploaded_file($t_name,$dir."/".$nametwo))
                        echo 'File 3 uploaded successfully';
              else
                        echo '...File 3 upload failed or was not submitted!  ';
              $namethree=basename($_FILES['file_uploadthree']['name']);
              $t_name=$_FILES['file_uploadthree']['tmp_name'];
              $dir='imagefour';
              // Validate uploaded image file
              if ( !preg_match( '/gif|png|jpeg/', $_FILES['file_uploadthree']['type']) ) {
                           die('<p>Only browser compatible images allowed</p></body></html>');
              } else if ( $_FILES['file_uploadthree']['size'] > 100000 )
                           die('<p>Sorry file too large</p></body></html>');
              if(move_uploaded_file($t_name,$dir."/".$namethree))
                        echo 'File 4 uploaded successfully';
              else
                        echo '...File 4 upload failed or was not submitted!  ';
              $namefour=basename($_FILES['file_uploadfour']['name']);
              $t_name=$_FILES['file_uploadfour']['tmp_name'];
              $dir='imagefive';
              // Validate uploaded image file
              if ( !preg_match( '/gif|png|jpeg/', $_FILES['file_uploadfour']['type']) ) {
                           die('<p>Only browser compatible images allowed</p></body></html>');
              } else if ( $_FILES['file_uploadfour']['size'] > 100000 )
                           die('<p>Sorry file too large</p></body></html>');
              if(move_uploaded_file($t_name,$dir."/".$namefour))
                        echo 'File 5 uploaded successfully';
              else
                        echo '...File 5 upload failed or was not submitted!  ';
              $namefive=basename($_FILES['file_uploadfive']['name']);
              $t_name=$_FILES['file_uploadfive']['tmp_name'];
              $dir='imagesix';
              // Validate uploaded image file
              if ( !preg_match( '/gif|png|jpeg/', $_FILES['file_uploadfive']['type']) ) {
                           die('<p>Only browser compatible images allowed</p></body></html>');
              } else if ( $_FILES['file_uploadfive']['size'] > 100000 )
                           die('<p>Sorry file too large</p></body></html>');
              if(move_uploaded_file($t_name,$dir."/".$namefive))
                        echo '    File 6 uploaded successfully';
              else
                        echo '....File 6 upload failed or was not submitted!  ';
              mysql_select_db ($database_XXXXXXXX,$XXXXXXXX); where XXXXXXXX is my database connection details. Please change to yours.
                        $qur=("insert into tbl_projects (projid, projcode, projname, projdesc, projappdate, projcommunity, projlga, projstate, projcost, projtype, projbaselinedata, Projexpoutcome, adultmen, adultfem, totalchildren, totalben, projteamlead, projdepteamlead, projofficer, projliasonofficer, projmeeting1, projmeeting2, projmeeting3, projmousigndate, projstartdate, projenddate, name, path, nameone, pathone, nametwo, pathtwo, namethree, paththree, namefour, pathfour, namefive, pathfive) VALUES ('', '$projcode','$projname','$projdesc', '$projappdate', '$projcommunity', '$projlga', '$projstate', '$projcost', '$projtype', '$projbaselinedata', '$Projexpoutcome', '$adultmen', '$adultfem', '$totalchildren', '$totalben', '$projteamlead', '$projdepteamlead', '$projofficer', '$projliasonofficer', '$projmeeting1', '$projmeeting2', '$projmeeting3', '$projmousigndate', '$projstartdate', '$projenddate','$name','imageone/$name','$nameone','imagetwo/$nameone', '$nametwo', 'imagethree/$nametwo', '$namethree', 'imagefour/$namethree', '$namefour', 'imagefive/$namefour', '$namefive', 'imagesix/$namefive')");
                        $res=mysql_query($qur,$XXXXXXXX);
    ?>
    Thank you. Hope this helps all those that are learning
    Message was edited by: Prince Mike

  • File Upload using Tomcat 5.x Apache 2.x

    Hi,
    Once I updated my tomcat 5.x to apache 2.x and ran my upload jsp code using java api i wrote to upload file to server, all pictures or videos received seems distorted.. At first i thought of bit shift or something but when i upload a textfile all look right.. Anyone know what the heck is going on before i disect my code.
    thanks
    henry

    make sure your modjk logs don't have any errors.
    Here's a peice out of my httpd.conf
    #ADDed Oct 15,2003, seemed to remove modjk error
    AddType multipart/form-data .gif .png  .jpg .peg .jpeg .jpeI used to get strange modjk logged errors.
    Also did you compile jk2 from source???
    com.oreilly.servlet --- cos
    http://www.servlets.com/cos/index.html
    http://www.servlets.com/cos/cos-05Nov2002.zip
    But if my bit shift is correct wouldn't my regular textfile upload be distored?From what I remember, the problem is something to do with logical AND or OR, with the bits. Apache receives it fine, passess it through jk, and and either the most sig or least gets lost. Image data is critical as every bit counts, text file, you may not notice it(white space), or every nTH file upload might fail.
    here are the version numbers of software I use, and have compiled all from source.
    apache-httpd-2.0.47
    tomcat-4.1.27
    jk2-connectors-2.0.2

  • File Upload using PRC API's

    Guys,
    I am trying to upload a new document using PRC API's. Below is required code snippet that i am using.
    IRemoteDocument remoteDoc = documentManager.createRemoteDocument(folderID,dataSourceID,document.getPath()); remoteDoc.setOverrideName(document.getName()); remoteDoc.setOverrideDescription(document.getDescription()); remoteDoc.setType("http://www.plumtree.com/dtm/mime", document.getFileType());int docID = -1;docID = remoteDoc.save();
    dataSourceID - ID of my file upload datasource , document - is my java object which has all the document related properties such as , name , description , MIME type of document etc..Below is different document path's(scenarios) that I have triedc:\work\sample.txt\\servername\work\sample.txthttp:\\appserver:7001\appName\uploadfiles\sample.txt
    When I execute this code from my application i get a below error.
    com.plumtree.remote.prc.PortalException: null; nested exception is: java.rmi.RemoteException: Error in function PTDataSource.ImportDocument(vDocumentLocationBagAsXML == '<?xml version="1.0" encoding="ucs-2"?><PTBAG V="1.1" xml:space="preserve"><I N="PTC_DTM_SECT">1001</I><S N="PTC_DOC_ID">application/msword</S><S N="PTC_UNIQUE">\\PHUSEH-L33664.NA.novartis.net\work\sample.doc</S></PTBAG>', lDocumentTypeID == 100, pCard == com.plumtree.server.impl.directory.PTCard@c27b6f, bSummarize == false, pProvider == null): Error in function PTDataSource.ImportDocument (vDocumentLocationBagAsXML == <?xml version="1.0" encoding="ucs-2"?><PTBAG V="1.1" xml:space="preserve"><S N="PTC_DOC_ID">application/msword</S><I N="PTC_DTM_SECT">1001</I><S N="PTC_UNIQUE">\\PHUSEH-L33664.NA.novartis.net\work\sample.doc</S></PTBAG>, lDocumentTypeID == 100, pCard == com.plumtree.server.impl.directory.PTCard@c27b6f, bSummarize == false, pProvider == null): SOAP fault: faultcode='soapenv:Server.userException' faultstring='java.lang.NullPointerException' at com.plumtree.remote.prc.DocumentWrapper.save()
    Below is my environment.Plumtree is running on Weblogic 8.1 (Solaris OS) , ptupload webservice is running on weblogic8.1 solaris,My upload document portlet is running on weblogic 8.1 (Windows OS)
    If anyone has any working sample code please send it to my ID [email protected] or else please upload it here.Thank You ,
    Dan.

    make sure your modjk logs don't have any errors.
    Here's a peice out of my httpd.conf
    #ADDed Oct 15,2003, seemed to remove modjk error
    AddType multipart/form-data .gif .png  .jpg .peg .jpeg .jpeI used to get strange modjk logged errors.
    Also did you compile jk2 from source???
    com.oreilly.servlet --- cos
    http://www.servlets.com/cos/index.html
    http://www.servlets.com/cos/cos-05Nov2002.zip
    But if my bit shift is correct wouldn't my regular textfile upload be distored?From what I remember, the problem is something to do with logical AND or OR, with the bits. Apache receives it fine, passess it through jk, and and either the most sig or least gets lost. Image data is critical as every bit counts, text file, you may not notice it(white space), or every nTH file upload might fail.
    here are the version numbers of software I use, and have compiled all from source.
    apache-httpd-2.0.47
    tomcat-4.1.27
    jk2-connectors-2.0.2

  • File Uploads using stored procedures

    Hello, I'm quite new here, but I have a question that I've been butting my head against for the past day. Here goes.
    We need to upload a file using a stored procedure (PL/SQL procedure.)
    The two things I have found that work are
    1) Having oracle do the file handling (using bfiles) in the procedure
    2) using an insert statement directly to upload the file contents into a blob.
    The platform is php (Oracle instant client) and I will show some code examples.
    1) is unworkable because Oracle will not have direct access to any files.
    2) is fine, but we would prefer to use a procedure so as to abstract what exactly goes on and possibly other operations away from the php and the framework.
    What worked:
    1)
    CREATE OR REPLACE PROCEDURE php_upload_file (file_name in varchar2, canonical_name in varchar2, owner in number, file_id IN OUT number)
    AS
    src_loc bfile:= bfilename('DOC_LOC',php_upload_file.file_name);
    dest_loc BLOB;
    begin
    insert into files values(owner,canonical_name,empty_blob(),files_seq.nextval) returning files.data, files.file_id
    into dest_loc, file_id;
    dbms_lob.open(src_loc,DBMS_LOB.LOB_READONLY);
    DBMS_LOB.OPEN(dest_loc, DBMS_LOB.LOB_READWRITE);
    DBMS_LOB.LOADFROMFILE(
    dest_lob => dest_loc
    ,src_lob => src_loc
    ,amount => DBMS_LOB.getLength(src_loc));
    DBMS_LOB.CLOSE(dest_loc);
    DBMS_LOB.CLOSE(src_loc);
    COMMIT;
    end;
    'DOC_LOC' is a directory I've set up that the user has access to.
    Interfacing with PHP this just looks like
    oci_parse($conn,"BEGIN php_upload_file('{$uploadfilename}','{$propername}',{$ownerid},:file_id); END;");
    Dead simple, right?
    I also do a bind command to pull out 'file_id' so I know the id that was just inserted.
    The other solution is
    $contents = file_get_contents($_FILES["uploadedfile"]["tmp_name"]);
    $lob = oci_new_descriptor($conn, OCI_D_LOB);
    $stmt = oci_parse($conn,
    "INSERT INTO files (employee_id, filename, data, file_id) VALUES(175,'"
    .$_FILES["uploadedfile"]["name"].
    "', empty_blob(), files_seq.nextval) RETURNING file_id, files.data INTO :file_id, :src_contents");
    where :src_contents is binded to a lob and :file_id as before is binded to an INT:
    oci_bind_by_name($stmt, ':src_contents', $lob, -1, OCI_B_BLOB);
    oci_bind_by_name($stmt, ':file_id', $insert_id, -1, SQLT_INT);
    oci_execute($stmt,OCI_DEFAULT);
    In this case the last thing I do before the commit is
    $lob->save($contents);
    Both work fine, but what I need is this
    $contents = file_get_contents($_FILES["uploadedfile"]["tmp_name"]);
    $lob = oci_new_descriptor($conn, OCI_D_LOB);
    $stmt = oci_parse($conn,"BEGIN do_upload_file(:src_contents,'{$propername}',{$ownerid},:file_id); END;");
    oci_bind_by_name($stmt, ':src_contents', $lob, -1, OCI_B_BLOB);
    oci_bind_by_name($stmt, ':file_id', $insert_id, -1, SQLT_INT);
    oci_execute($stmt,OCI_DEFAULT);
    $lob->save($contents);
    oci_commit($conn);
    this omits error conditions (such as on $lob->save ... etc.) it is simplified.
    The content of the procedure I changed as follows, but it seems untestable.
    CREATE OR REPLACE PROCEDURE do_upload_file (src_contents IN OUT blob, canonical_name in varchar2, owner in number, file_id IN OUT number)
    AS
    dest_loc BLOB;
    begin
    insert into files values(owner,canonical_name,empty_blob(),files_seq.nextval) returning files.data, files.file_id
    into dest_loc, file_id;
    dbms_lob.open(src_contents,DBMS_LOB.LOB_READONLY);
    DBMS_LOB.OPEN(dest_loc, DBMS_LOB.LOB_READWRITE);
    DBMS_LOB.COPY(dest_lob => dest_loc,
    src_lob => src_contents
    ,amount => DBMS_LOB.getLength(src_contents));
    DBMS_LOB.CLOSE(dest_loc);
    DBMS_LOB.CLOSE(src_contents);
    COMMIT;
    end;
    I don't get errors because I cannot figure out a way to run this procedure in my PL/SQL environment with valid data. (I can run it with a blank blob.)
    But when I work out the order of what's going on, it doesn't make sense; the commit in the procedure is before the $lob->save(...) and thus it would never save the data... nonetheless it should at least create a record with an empty blob but it does not. What is wrong is beyond the error level that seems to be supported by PHP's oci_error function (unless I have not discovered how to turn all errors on?)
    In any case I think the logic is wrong here, but I'm not experienced enough to figure out how.
    To test it I would need to create a driver that loads an external file into a blob, and passes that blob into the procedure. Trouble is, even if I make a blob and initialize it with empty_blob() it treats it as an invalid blob for the purposes of the dbms_lob.copy procedure.
    If someone has solved this problem, please let me know. I would love to be able to do the file upload with just a single procedure.

    Thanks. In my estimation that is exactly the issue. But that doesn't help with a resolution.
    The actual file size: 945,991 bytes
    If Firefox is miscalculating the length (in Safari/Chrome 945991 and 946241 in Firefox), then Firefox is reporting erroneously and should be raised as a bug in Firefox, would you agree?

  • Issues with file upload in flex mobile application (sharepoint as backend)

    Hello,
    I am working on flex mobile application for android platform for which we are having sharepoint as a backend.
    (Flex SDK 4.6 and AIR 3.9)
    Issue which we are facing is as follows:
    We are communicating with the backend server using webservices: example:
    <s:WebService id="kWebService" wsdl="http://www.kservice.net/kdatabaseservice.asmx?WSDL" >
                <s:operation name="AddPost"
                             resultFormat="object"
                             result="addPostResult(event)"
                             fault="postsfaulterr(event)" />
    </s:WebService>
    Above services are working fine but we are facing issue with one service which is related to file upload.
    File upload for <10 MB is working fine but when we try to upload larger file on server it fails to process.
    We are sending bytearray to the backend and backend code is writing those bytearray into file.
    We have tried many ways to overcome from this situation. like we have checked configuration for file upload size on server , we have tried wcf services as well. Please help us on this criticle point as soon as possible
    Thanks
    Dhwani

    Prashant8809 wrote:
    Hi
    >
    > I have already gone through the video by Thomas Jung for multiple file upload but it saves the contents in server and not in >transparent table. So please suggest me alternative solutions.
    >
    >
    > Regards
    > Prashant Chauhan
    What do you mean that my video saves the contents int he server and not in transparent table?  I save the data into a temporary database table so it can be accessed by the parent WDA session. From there the WDA session can do whatever it wants with it.  What do you mean by transparent table - that would be a database table. Do you actually mean internal table?  if so, just read the data from the temporary database table into memory.

  • File Upload Using BAPI

    Hi all,
         I'm facing a problem during uploading an file through BAPI from WebDynpro Application.
    The BAPI im using is 'BAPI_DOCUMENT_CREATE2'.
    this works well in R/3 But when used in WebDynpro it is not working. It indicates with an error of 'Error while looking and saving the particular file'.
    Could anyone tell me what is the problem

    Well you are getting into the specifics of this BAPI, of which I am limited with the help I can give because I don't have access to an ECC system.  However if I remember right this BAPI does allow you to specify the upload desitnation and you can override the SAPFTP with SAPFTPA.  The parameter name is PF_FTP_DEST if memory serves me. This will instead upload the document from the application server instead of the frontend.
    So what you can do is still use the fileUpload UI element in WDA, but then write the file content back into the local App server file system using the ABAP DATASET commands.  You can then call the BAPI passing the file location on the application server and telling it to use the SAPFTPA upload method. 
    The core of the problem is the BAPI was designed to perform the upload itself.  It would actually be easier now if it just accepted a binary string as an input parameter that contained the document content. But oh well, you must work with what you have.

Maybe you are looking for