Get filesize and filename of uploaded file

Hello -
I am somewhat of a newbie and am need of some assistance.  I am using ADT to upload a file and save to a database along with its filename and filesize.  The file uploads fine, but the filename and size are not being recorded in the database. Other fields that are part of the upload form save to the dB fine.
Here's the basic code:
// Add columns
$ins_UserBackgroundPapers->addColumn("FileContainer", "FILE_TYPE", "FILES", "FileContainer");
$ins_UserBackgroundPapers->addColumn("FileName", "STRING_TYPE", "POST", "FileName");
$ins_UserBackgroundPapers->addColumn("FileSize", "STRING_TYPE", "POST", "FileSize");
<form name="form1" method="POST" id="form1" action="<?php echo $editFormAction; ?>" enctype="multipart/form-data">
     <input type="file" name="FileContainer" id="FileContainer" size="32" />
     <input name="FileName" id="FileName"  type="hidden" value="<?php echo $HTTP_POST_FILES['FileContainer']['name']?>" />
     <input name="FileSize" id="FileSize" type="hidden" value="<?php $HTTP_POST_FILES['FileContainer']['size'];?>" />
     <input class="submit" type="submit" name="KT_Insert1" id="KT_Insert1" value=";Upload"/>
</form>
I've also tried using $_FILES["FileContainer"]["name/size"] with no luck.
Any help would be much appreciated. I'm desperate!
Thanks.

I think the main issue is that the file name does - unlike expected - not get stored in the FileContainer column, but I don´t have any idea why this happens without seeing the complete code of the page in question.
In regards to retrieving the file size:
Those hidden fields you´re trying to make use of:
     <input name="FileName" id="FileName"  type="hidden" value="<?php echo $HTTP_POST_FILES['FileContainer']['name']?>" />
     <input name="FileSize" id="FileSize" type="hidden" value="<?php $HTTP_POST_FILES['FileContainer']['size'];?>" />
...can´t capture the additional info you want, because the very moment the form data gets submitted, the file itself has not neccesarily been uploaded yet, in particular when ADDT´s File Upload trigger has been set to AFTER -- and it´s important to consider that the $HTTP_POST_FILES[] values are assigned at the server side and not by the browser anyway.
However, additional information such as the size of an uploaded file doesn´t need to be stored anyway, because such information is easily retrievable by using the PHP function "filesize": http://de.php.net/filesize
Cheers,
Günter
P.S: $HTTP_POST_FILES[] is deprecated since PHP version 4.1.0 -- better use $_FILES instead: http://us3.php.net/manual/en/reserved.variables.files.php

Similar Messages

  • I have a Seagate Slim Portable 500 GB USB 3.0 external hard drive that worked great with my Macbook Pro 13" Retina but gets ejected and won't show files on any iMac.

    I have a Seagate Slim Portable 500 GB USB 3.0 external hard drive that worked great with my Macbook Pro 13" Retina but gets ejected and won't show files on any iMac. My Macbook Pro and the two different iMacs I tried it on were all using Mountain Lion, so the only difference was the iMac versus Macbook Pro.

    I just tried this, no luck...
    I connected a different USB cable, still the same problem. Tried both cables with the problematic hard drive on two different computers, still the same problem.
    At this point I assume I'll probably need professional help in saving the files, thanks for the assistance.

  • Can Anyone help with syncing my contacts are getting duplicated and there is a file from my computer and they are not the same it is driving me carazy can anyone help?

    Can Anyone help with syncing my contacts are getting duplicated and there is a file from my computer and they are not the same it is driving me carazy can anyone help?

    Are you in DSL? Do you know if your modem is bridged?
    "Sometimes your knight in shining armor is just a retard in tin foil.."-ARCHANGEL_06

  • How to get the content of the uploaded file.

    Hi Experts,
    I am using a input box to get the path of the file to be uploaded.(I am not using FILE UPLOAD UI Element).Could you please let me know how to get the content of the uploaded file.
    Regards,
    Arun

    >
    ARUN KUMAR.S wrote:
    > Hi Experts,
    >
    > I am using a input box to get the path of the file to be uploaded.(I am not using FILE UPLOAD UI Element).Could you please let me know how to get the content of the uploaded file.
    >
    > Regards,
    > Arun
    You will not be able to use a normal InputField to upload file contents.  This is not allowed by the browser security model. You must use one of the upload specific UI mechanisms - the FileUpload UI element or as of 7.01 ACFUpDownload or FlashIslands.

  • I can't download Ikea 3D kitchen planner.  It's really frustrating - a message is appearing on my mac book pro that I ned to get info and check that various files are unlocked.  I've checked that all other requirements are fulfilled, still won't download

    I can't download Ikea 3D kitchen planner.  It's really frustrating - a message is appearing on my mac book pro that I ned to get info and check that various files are unlocked.  I've checked that all other requirements are fulfilled, still won't download.  Any help very gratefully received.  Thank you.

    Hi, I'm not really very good with computers and am having the same problems when trying to install the Ikea 3D kitchen planner, please could you take me through the steps?
    1. Download (save) the disk image file 2020PluginInstaller.dmg
    I double click on the link which says "Install 3D Planner"
    I agree to the t&cs
    A file downloads to my download folder called 2020PluginInstaller_IKEA.dmg
    2. Mount the disk image (open/run the downloaded file) if not mounted automatically
    I double click on the downloaded file
    3. Find the 2020PluginInstaller window (might be behind the window on top)
    A small window opens up with a lego brick called 2020PluginInstaller_IKEA.dmg and a folder called Internet plug ins.  I highlight the lego brick and do File, Get info and unlock it
    4. Drag the lego piece to the folder (if you do not have admin privileges you will be prompted to authenticate)
    I do this and put in a password to authenticate
    5. Restart the browser (it is not enough to close the browser window, you need to restart the browser
    application)
    I've tried restarting Safari, I've tried re-starting the computer
    6. Access the same link and you will now see the Start button and be able to start planning your room!"
    When I go back to the IKEA kitchen planner I don't see a start button, I just see the exact same screen as before prompting me to install the 3D planner
    Please can you help?

  • Getting extra things in the uploaded file by flex file upload

    Hi,
    I am working on a application where I am using adobe flex. I
    have a requirement wher I have to upload file to the server. System
    allows user to browse file from local machine and flex uploads it
    to the server.
    Now there is a upload url, its a jsp page which gets
    mutipart/form-data content from the request, opens an outputstream
    and writes the content of the inputstrem to the file.
    fileUpload.mxml
    quote:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="vertical" creationComplete="initApp()">
    <mx:Script>
    <![CDATA[
    import mx.controls.Alert;
    import mx.utils.ObjectUtil;
    import flash.events.*;
    import flash.net.FileReference;
    import flash.net.URLRequest;
    private var fileRef:FileReference;
    private function initApp():void {
    fileRef = new FileReference();
    fileRef.addEventListener(Event.CANCEL, traceEvent);
    fileRef.addEventListener(Event.COMPLETE, completeEvent);
    fileRef.addEventListener(Event.SELECT, selectEvent);
    fileRef.addEventListener(IOErrorEvent.IO_ERROR, traceEvent);
    fileRef.addEventListener(Event.OPEN, traceEvent);
    fileRef.addEventListener(ProgressEvent.PROGRESS,
    progressEvent);
    fileRef.addEventListener(SecurityErrorEvent.SECURITY_ERROR,
    traceEvent);
    private function traceEvent(event:Event):void {
    var tmp:String = "================================\n";
    //ta.text += tmp + event.type + " event:" +
    mx.utils.ObjectUtil.toString(event) + "\n" ;
    //ta.verticalScrollPosition += 20;
    private function ioErrorEvent(event:IOErrorEvent):void{
    Alert.show("IOError:" + event.text);
    traceEvent(event);
    private function selectEvent(event:Event):void{
    btn_upload.enabled = true;
    traceEvent(event);
    filename.text = fileRef.name;
    progressBar.setProgress(0, 100);
    progressBar.label = "Loading 0%";
    private function progressEvent(event:ProgressEvent):void {
    progressBar.setProgress(event.bytesLoaded,
    event.bytesTotal);
    traceEvent(event);
    private function completeEvent(event:Event):void {
    progressBar.label = "Complete.";
    filename.text += " uploaded";
    traceEvent(event);
    btn_upload.enabled = false;
    btn_cancel.enabled = false;
    private function uploadFile(endpoint:String):void {
    var param:String = "author=" + ti_author.text;
    var req:URLRequest = new URLRequest(endpoint);
    req.method = URLRequestMethod.POST;
    fileRef.upload(req, param, false);
    progressBar.label = "Uploading...";
    btn_cancel.enabled = true;
    ]]>
    </mx:Script>
    <mx:Panel title="Flex 2 File Uploading Demo" width="100%"
    height="100%" >
    <mx:Form>
    <mx:FormItem label="Upload URL:">
    <mx:TextInput editable="false" id="uploadURL"
    width="100%" text="
    http://localhost/flexApp/jsps/upload.jsp"
    enabled="true" />
    </mx:FormItem>
    <mx:FormItem label="Selected File:">
    <mx:Label id="filename"/>
    </mx:FormItem>
    <mx:FormItem label="Upload By:">
    <mx:TextInput id="ti_author" text="Author" />
    </mx:FormItem>
    <mx:FormItem direction="horizontal" width="100%">
    <mx:Button width="80" label="Browse"
    click="fileRef.browse()" />
    <mx:Button width="80" label="Upload" id="btn_upload"
    enabled="false" click="uploadFile(uploadURL.text)" />
    <mx:Button width="80" label="Cancel" id="btn_cancel"
    enabled="false" click="fileRef.cancel()" />
    </mx:FormItem>
    <mx:HRule width="100%" tabEnabled="false"/>
    <mx:FormItem label="Progress:">
    <mx:ProgressBar id="progressBar" mode="manual" />
    </mx:FormItem>
    </mx:Form>
    </mx:Panel>
    </mx:Application>
    test.jsp page
    quote:
    InputStream is = null;
    BufferedInputStream bis = null;
    BufferedOutputStream bos = null;
    try {
    System.out.println("request.getContentType()...." +
    request.getContentType());
    is = request.getInputStream();
    bis = new BufferedInputStream(is);
    bos = new BufferedOutputStream(new FileOutputStream(new
    File("d:/naseem.txt")));
    int i=0;
    while ((i = bis.read())!=-1) {
    bos.write(i);
    bos.flush();
    catch(Exception e){
    e.printStackTrace();
    finally{
    try{
    if(bos!=null && is!=null && bis!=null){
    bos.close();is.close();bis.close();
    }catch(Exception e){e.printStackTrace();}
    Above jsp writes the content of browsed file to d:/naseem.txt
    Problem which I am facing is besides the actual content, it
    also write something else.
    Actual file:
    quote:
    My Text
    upload txt file which I got: naseem.txt
    quote:
    ------------cH2ei4GI3ae0KM7cH2GI3ei4ae0cH2
    Content-Disposition: form-data; name="Filename"
    test.txt
    ------------cH2ei4GI3ae0KM7cH2GI3ei4ae0cH2
    Content-Disposition: form-data; name="author=Author";
    filename="test.txt"
    Content-Type: application/octet-stream
    My Text
    ------------cH2ei4GI3ae0KM7cH2GI3ei4ae0cH2
    Content-Disposition: form-data; name="Upload"
    Submit Query
    ------------cH2ei4GI3ae0KM7cH2GI3ei4ae0cH2--
    My question is how do I remove these content-disposition,
    content type i.e., extra things from my file. I need only content
    to be written in the file.
    Regards,
    Naseem

    Hi Naseem,
    You need a multipart request parsing utility. Check commons-fileupload for example.

  • Filename of uploaded file through messageFileUpload in table

    Hi,
    i have a table bean on a page where there is a single column of type messageFileUpload. User can add rows to table and upload files to db table containing columns file_name (varchar2) and file_data (blob). How can i populate the db table column file_name with the name of the file choosen by the user?
    If i do not use table (just a single messageFileUpload component) then on form submit in processFormRequest i can use String fileName = pageContext.getParameter("FileData"); to get the name of file, but waht to do with a messageFileUpload in a table?
    Edited by: user12086842 on 01.01.2013 3:46

    Thanks for reply.
    I replaced messageFileUpload (binded to blob table column) with messageStyledText (binded to filename attribute). Above the table placed single messageFileUpload and submitButton nearby. After user select file on submit I do:
    *if (pageContext.getParameter("DoUploadButton") != null) {*
    .. DataObject fileUploadData = pageContext.getNamedDataObject("FileData");
    .. *if (fileUploadData != null) {*
    .... String fileName = (String)fileUploadData.selectValue(null, "UPLOAD_FILE_NAME");
    .... String contentType = (String)fileUploadData.selectValue(null, "UPLOAD_FILE_MIME_TYPE");
    .... BlobDomain fileContent = (BlobDomain)fileUploadData.selectValue(null, fileName);
    .... String seqNumber = pageContext.getParameter("seqNumber");
    .... am.insertInstanceAttachRowBlob(seqNumber, fileName, fileContent, contentType);
    .... pageContext.removeNamedDataObject("FileData");
    .. return;
    Edited by: user12086842 on 02.01.2013 2:41

  • How to get the charset of the uploaded file

    I am uploading xml files through apex application to the database server, then I will create xmltype from it. How would I know the charset of the xml file? There is a file_charset column in apex_application_files table. However it is null when I upload the xml file. How is this column used? Any help will be appreciated.
    -Fengting

    I found that there is a file_charset column in table apex_application_files. I thought apex will figure out the file charset and populate that column in the table after uploading the file. But it was null in my case. If I prompt the user to specify the charset, the charset value won't go into apex_application_files table.
    It is true that an XML file is typically encoded in utf8 but there could be exceptions. When I create xmltype from the uploaded file in a blob, I need to provide the charset_id in the xmltype constructor. I hope I can provide the correct charset instead of a typical value of utf8.
    So there is no standard or recommended way to get the file character set other than prompting to user?
    Thanks,
    -Fengting

  • SQL*Loader and unzipping with uploaded file

    hi, everybody
    i was trying to integrate some functionalities, today separated. i made a simple Apex page that uploads a file, and now i need to process that file.
    is there any way to process that uploaded file and load it onto a table, just like i'd do with Sql*Loader?
    in the same way, can i unzip an uploaded zip file, just like Oracle Portal 3.0.9 used to do in its contect areas with zip itens?
    thanks

    Hi, Ivo
    about ult_compress, ok. i'll check it out.
    talking about uploaded files, the only thing i've found were:
    a) download an uploaded file
    b) use an uploaded image to integrate in a web application.
    unfortunately, i didn't find anything that could help me process an uploaded text file the way i do with SQL*Loader.
    i'll keep on trying
    thanx

  • Get filename from uploaded file then place in input tags

    i have an upload feature with the use of upBean and i can get the filname thru filename=file.getFileName
    when i place in the input tags it takes an error what i suppose to do
    <input type="hidden" name="getfilename" value="<%=filename%>">
    if (MultipartFormDataRequest.isMultipartFormData(request)) {
                            // Uses MultipartFormDataRequest to parse the HTTP request.
                            MultipartFormDataRequest mrequest = new MultipartFormDataRequest(request);
                            String todo = null;
                            String filename=null;
                            String description=request.getParameter("txtDesc");
                            String checkfilename=mrequest.getParameter("uploadfile");
                            if (mrequest != null) todo = mrequest.getParameter("todo");
                            if ( (todo != null) && (todo.equalsIgnoreCase("upload")) ) {
                                Hashtable files = mrequest.getFiles();
                                if ( (files != null) && (!files.isEmpty()) && (description!=null)) {
                                    UploadFile file = (UploadFile) files.get("uploadfile");
                                    if (file != null){
                                        filename=file.getFileName();                                    if(checkfilename==null){
                                            filename="";
                                  upBean.store(mrequest, "uploadfile");  // Uses the bean now to store specified by jsp:setProperty at the top.
                                             else out.println("<BR> todo="+todo);
                    %>
                    Message was edited by:
    BlingBling15

    Thanks for reply.
    I replaced messageFileUpload (binded to blob table column) with messageStyledText (binded to filename attribute). Above the table placed single messageFileUpload and submitButton nearby. After user select file on submit I do:
    *if (pageContext.getParameter("DoUploadButton") != null) {*
    .. DataObject fileUploadData = pageContext.getNamedDataObject("FileData");
    .. *if (fileUploadData != null) {*
    .... String fileName = (String)fileUploadData.selectValue(null, "UPLOAD_FILE_NAME");
    .... String contentType = (String)fileUploadData.selectValue(null, "UPLOAD_FILE_MIME_TYPE");
    .... BlobDomain fileContent = (BlobDomain)fileUploadData.selectValue(null, fileName);
    .... String seqNumber = pageContext.getParameter("seqNumber");
    .... am.insertInstanceAttachRowBlob(seqNumber, fileName, fileContent, contentType);
    .... pageContext.removeNamedDataObject("FileData");
    .. return;
    Edited by: user12086842 on 02.01.2013 2:41

  • Get the absolute path and filename of the file from the command line

    Hi,
    when we run the class we give the command
    java <filename>
    How can I capture the filename given above and get its absolute path inside the
    public static void main(String [] args){}
    args[0] gives me the command line argument after the filename. How do I capture the filename itself from the command line argument and also get that files absolute path
    Thanks

    I don't know of any way to capture the java command input, but there are ways to find out where the application is being run from. (the "absolute path")
    http://forum.java.sun.com/thread.jsp?forum=31&thread=335394

  • How to get the format of the uploaded file ?

    Hi !!
    I am developing a web application, which allows user(client) to upload a file.
    I have to place that file in corresponding directory like image, sound, text on server-side.Here........ I am facing a problem to find the Format of that file.
    I used 'ImageInfo.java' to find the format of the image files and I am unable to find the format of the Text, Sound files.
    if user changed the file name from 'file.txt' to 'file.jpg', the action class has to indentify it. Vice Versa......
    Please Help me !!!!!
    Thanks in Advance :-)

    Thank you.
    Yes, you are right!!!
    But i am using ' org.apache.struts.upload ' package . where getContentType() method in this package, gets the mimeType of the file. Its returning the type- by its extension not by its (File)Format.
    I don't know ... I am trying to find the solution.....
    Once again thanks.........

  • Firefox 3.0- no problems uploading files to You Send It- now with 3.6 I get error message. Cannot upload files. Please fix this glitch.

    I was really really happy with firefox 3.0. But 2 days ago I had to upgrade to 3.6.12 in order to use Constant Contact.. I am really really really upset. I tried to send an mp4 file using You Send It and I keep getting an error message. I tried to upload a file I sent 3 days ago using firefox 3.0 and it uploaded and sent with ease. Now I cannot send any files and I am really angry as I use You Send It for my clients. I will probably have to start using a different browser if you cannot fix this problem.

    Exactly what was the error message you received?
    Have you tried using YouSendIt support? <br />
    http://www.yousendit.com/support <br />
    More than likely it is a problem that is easily fixed within that application, and not directly a Firefox issue.

  • How to get audio and video in one file

    hi...I am "premiere beginner user" and I have a simple question , I think..:)...Every time when I am trying to export media out from my premiere (using media encoder) I get video file and some audio files, but what I need is only ONE file, that contains both (audio and video)..for example , I have edited film in hd quality and I want it to export, I choose h.264 format(make some settings,pal,audio quality...) and when it´s "all done", only "result" I get is one video file and two audio files and they are not together :).....so please help mme anyone..ok and as you can see I am not from english speaking country, so sorry for my english...thanks for help....

    There is no indication that something is out-of-sync or the ability to move/slip into sync like in FCE/FCP.
    To the best of my knowledge, using match frame and overwriting the video with video+audio (or attaching it as a connected clip if you don't want to overwrite the video, which might have effects applied) is the best way to do this.
    You can use the blade tool first in the timeline to get just the section you want to get back into sync. Make cuts so that you have a single clip that needs the audio resynced, select it, and use shift-F to select the original synced clip in the Event Browser. Make sure your play head is at the beginning of this video clip in the timeline. Press option-2, then 'q', and now you have the audio back in your timeline, synced with the video.  Delete the old, no-longer-synced audio and you should be set.

  • Change filename of uploaded file

    I am using fileupload from Apache common. Is there a way I can change file name of file being uploaded?

    Hi,
    I cannot see a workaround and doesn't appear possible as the system will only append the unique ID which cannot be customized at this stage. 
    Kind regards,
    -Sidney

Maybe you are looking for

  • The crash happened outside the java virtual machine in native code

    Hi, I have a biometric device with which I am given some C++ dlls. I am trying to call methods inside these using java (jna). I am loading the dll "zkemsdk.dll+" as follows: zkemkeeper INSTANCE1 = (zkemkeeper)Native.loadLibrary("zkemsdk", zkemkeeper.

  • PSE11 stops working and is causing errors in the Reliablity Report Windows 8

    I keep getting this error code can anyone assist me? I have had several calls into Adobe and the last person said if it is working disregard the error. I get that but it is effecting my performance. I have uninstalled twice and reinstalled it twice a

  • Is possible change the title with Acrobat Pro 9?

    Hi, I'm using Acrobat Pro. 9, and i'm programing with C#. My question is: Is possible change de title in a pdf? I'm using this two metods and nothing the nothing, the title no change. ---- 1 form ------ PdfStamper pdfStamper = null; pdfStamper = new

  • OS "Stutters" after screensaver/monitor sleep

    I know this sounds incredibly odd, but just recently whenever I bring my mac out of a screen saver or if the monitor has gone to sleep, the entire system will stutter until I restart the system. Even the harddrive will have noticeable "pauses" in spi

  • ME5J: Scope Of List.

    Hi all. I have one requirement for that i have copied program of tr ME5J i.e. RM06BKPS as ZRM06BKPS. but when i execute this program in ALV format i get error that <b>Scope of list ALV not defined (please correct)</b>, so how can i run this program.