الانتقال إلى المحتوى
View in the app

A better way to browse. Learn more.

مجموعة مستخدمي أوراكل العربية

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Upload Download File

Featured Replies

بتاريخ:

السلام عليكم 

عملت تطبيق يقوم بتحميل ملفات الى السيرفر بأستخدام الطريقة الموجود في المدونه التالية

http://www.awasthiashish.com/2014/08/uploading-and-downloading-files-from.html

 

في هذه الطريقة اكبر حجم يمكن رفعة هو 2MB

المطلوب كيف يمكن زيادة حجم الملف عن 2MB 

وبأستخدام الكود التالي

Bean Method to Upload File
/**Method to upload file to actual path on Server*/
    private String uploadFile(UploadedFile file) {

        UploadedFile myfile = file;
        String path = null;
        if (myfile == null) {

        } else {
            // All uploaded files will be stored in below path
            path = "D://FileStore//" + myfile.getFilename();
            InputStream inputStream = null;
            try {
                FileOutputStream out = new FileOutputStream(path);
                inputStream = myfile.getInputStream();
                byte[] buffer = new byte[8192];
                int bytesRead = 0;
                while ((bytesRead = inputStream.read(buffer, 0, 8192)) != -1) {
                    out.write(buffer, 0, bytesRead);
                }
                out.flush();
                out.close();
            } catch (Exception ex) {
                // handle exception
                ex.printStackTrace();
            } finally {
                try {
                    inputStream.close();
                } catch (IOException e) {
                }
            }

        }
        //Returns the path where file is stored
        return path;
    }
AMImpl method to insert record in table for Uploaded file
 
/**Method to set file path and name
     * @param name
     * @param path
     */
    public void setFileData(String name, String path,String contTyp) {
        ViewObject fileVo = this.getFileUpdDwn1();
        Row newRow = fileVo.createRow();
        newRow.setAttribute("FileName", name);
        newRow.setAttribute("Path", path);
        newRow.setAttribute("ContentType", contTyp);
        fileVo.insertRow(newRow);
        this.getDBTransaction().commit();
        fileVo.executeQuery();
    }
ValueChangeListener to execute all methods 
/*****Generic Method to Get BindingContainer**/
    public BindingContainer getBindingsCont() {
        return BindingContext.getCurrent().getCurrentBindingsEntry();
    }

    /**
     * Generic Method to execute operation
     * */
    public OperationBinding executeOperation(String operation) {
        OperationBinding createParam = getBindingsCont().getOperationBinding(operation);
        return createParam;

    }

    /**Method to Upload File ,called on ValueChangeEvent of inputFile
     * @param vce
     */
    public void uploadFileVCE(ValueChangeEvent vce) {
        if (vce.getNewValue() != null) {
            //Get File Object from VC Event
            UploadedFile fileVal = (UploadedFile) vce.getNewValue();
            //Upload File to path- Return actual server path
            String path = uploadFile(fileVal);
            System.out.println(fileVal.getContentType());
            //Method to insert data in table to keep track of uploaded files
            OperationBinding ob = executeOperation("setFileData");
            ob.getParamsMap().put("name", fileVal.getFilename());
            ob.getParamsMap().put("path", path);
            ob.getParamsMap().put("contTyp", fileVal.getContentType());
            ob.execute();
            // Reset inputFile component after upload
            ResetUtils.reset(vce.getComponent());
        }
    }

 

 

  • الردود 47
  • المشاهدات 4.9k
  • البداية
  • اخر رد

أكثر المشاركين في هذا الموضوع

بتاريخ:

هذه إعدادات في web.xml

بتاريخ:
  • كاتب الموضوع

هذه إعدادات في web.xml

استاذ مصطفى يرجى من حضرتك شرح اين يمكن تعديلها في web.xml فلقد بحثت داخل web.xml ولم اجد 

بتاريخ:

لن تجده

هذا إعداد يتم إضافته

بتاريخ:
  • كاتب الموضوع

لن تجده

هذا إعداد يتم إضافته

عذرا وكيف اضيفها هل يوجد شرح على ذلك

بتاريخ:

لا يوجد شرح

هذا رقم يتم إضافته مع اسم القيمة المراد بها حجم الملف المرفوع

يمكنك البحث عنها في جوجل

اسم القيمة كبير نسبياً ولا أتذكره الآن

بتاريخ:
  • كاتب الموضوع

لا يوجد شرح

هذا رقم يتم إضافته مع اسم القيمة المراد بها حجم الملف المرفوع

يمكنك البحث عنها في جوجل

اسم القيمة كبير نسبياً ولا أتذكره الآن

جزاك اللة خير

بتاريخ:
  • كاتب الموضوع

شكرا استاذ مصطفى للتوضيح

تم حل المشكلة وهي زيادة حجم الملفات المرفوعة للسيرفر والتي كانت محدد بـ 2MB

ولفائدة الجميع الحل موجود في الرابط التالي 

 

https://docs.oracle.com/cd/E24382_01/web.1112/e16181/ap_config.htm#ADFUI579

 

 

حيث يجب اضافة اعدادات الى ملف web.xml

<context-param>
<!-- Maximum memory per request (in bytes) -->
<param-name>org.apache.myfaces.trinidad.UPLOAD_MAX_MEMORY</param-name> 
<param-value>512000</param-value>
</context-param>
<context-param>
<!-- Maximum disk space per request (in bytes) -->
<param-name>org.apache.myfaces.trinidad.UPLOAD_MAX_DISK_SPACE</param-name> 
<param-value>512000000</param-value>
</context-param>
بتاريخ:

نعم هذه هي

بتاريخ:
  • كاتب الموضوع

نعم هذه هي

شكرا لك منكم نتعلم 

بتاريخ:

العفو بالتوفيق

  • بعد 1 شهر...
بتاريخ:

السلام عليكم هل يمكنني بعد عمل upload  للملف تجيني رساله تأكيد ان الملف تم ارساله وكيف ذلك

بتاريخ:

يمكنك إظهار رسالة عن طريق FacesMessage

بتاريخ:

تمام الف شكر ياباشمهندس

بتاريخ:

العفو

بتاريخ:

اذن ما الخطأ في ذلك 

 

package view;
 
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
 
import javax.faces.application.FacesMessage;
 
import javax.faces.context.FacesContext;
 
import oracle.adf.model.BindingContext;
 
import oracle.binding.AttributeBinding;
import oracle.binding.BindingContainer;
 
import org.apache.myfaces.trinidad.model.UploadedFile;
 
public class UploadClass {
    
    private UploadedFile _File;
    public UploadClass() {
    }
 
    public String UploadProcess() {
        // Add event code here...
        
        String imagesFolder = "C:\\upload_id\\";
 
               File myFile = new File(imagesFolder);
 
               if ( !myFile.exists() )   {  myFile.mkdir(); }
 
               String newImageFile    = imagesFolder +  this.getCurrentId()+".rar";
 
               try {
 
                   InputStream inputStream         = getFile().getInputStream();
 
                   FileOutputStream outputStram    = new FileOutputStream(newImageFile);
 
 
                   byte[] buffer = new byte[8192];
 
                   int bytesRead = 0;
 
                  
 
                   while ((bytesRead = inputStream.read(buffer)) != -1) {
 
                       outputStram.write(buffer, 0, bytesRead);
 
                   }
 
                   outputStram.flush();
 
                   outputStram.close();
 
                   inputStream.close();
 
                   getFile().dispose();
 
                  
 
               } catch (FileNotFoundException fnfe) {
 
                   // TODO: Add catch code
 
                   fnfe.printStackTrace();
 
               } catch (IOException ioe) {
 
                   // TODO: Add catch code
 
                   ioe.printStackTrace();
 
               } 
 
        return null;
    }
    public void setFile(UploadedFile _File) {
 
           this._File = _File;
 
       }
 
    public UploadedFile getFile() {
 
          return _File;
 
      }
 
    public String getCurrentId() {
 
      BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
 
      AttributeBinding attr = (AttributeBinding)bindings.getControlBinding("Id"); 
 
      return  attr.getInputValue().toString().trim();
      
      
        
      
 
    }
    
        FacesMessage   message=new FacesMessage ("Success");
        message.setSeverity(FacesMessage.SEVERITY_INFO);
        FacesContext fc = FacesContext.getCurrentInstance(); 
        fc.addMessage(null, message);
        return null;
                            
               
 
}
بتاريخ:

السلام عليكم 

بعمل download ل file بالكود ده

    public String  downloadFileListener() throws IOException {
           HttpServletResponse response = getResponse();
           PrintWriter out = response.getWriter();  
          // ServletOutputStream out = response.getOutputStream();
          // response.setContentType("image/jpeg");
           response.setContentType("APPLICATION/OCTET-STREAM");
           String filename = it2.getValue().toString()+".jpg";  
           String filepath = "\\\\server_ip\\Certificate\\";   
           response.setContentType("APPLICATION/OCTET-STREAM");   
           response.setHeader("Content-Disposition","attachment; filename=\"" + filename + "\"");   
           FileInputStream fileInputStream = new FileInputStream(filepath + filename);  
                       
           int i;   
           while ((i=fileInputStream.read()) != -1) {  
           out.write(i);   
           }   
           fileInputStream.close();   
           out.close();   
           
        return null;
 

 

       }

 

 

 

 

 

 

 

 

بيطلعلى الerror ده ومبيخلينش اعمل اى حاجة فى الصفحة ازاى احل المشكلة دى

 

 

 

 

java.lang.IllegalStateException: Cannot forward a response that is already committed

بتاريخ:

 

اذن ما الخطأ في ذلك 

 

package view;
 
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
 
import javax.faces.application.FacesMessage;
 
import javax.faces.context.FacesContext;
 
import oracle.adf.model.BindingContext;
 
import oracle.binding.AttributeBinding;
import oracle.binding.BindingContainer;
 
import org.apache.myfaces.trinidad.model.UploadedFile;
 
public class UploadClass {
    
    private UploadedFile _File;
    public UploadClass() {
    }
 
    public String UploadProcess() {
        // Add event code here...
        
        String imagesFolder = "C:\\upload_id\\";
 
               File myFile = new File(imagesFolder);
 
               if ( !myFile.exists() )   {  myFile.mkdir(); }
 
               String newImageFile    = imagesFolder +  this.getCurrentId()+".rar";
 
               try {
 
                   InputStream inputStream         = getFile().getInputStream();
 
                   FileOutputStream outputStram    = new FileOutputStream(newImageFile);
 
 
                   byte[] buffer = new byte[8192];
 
                   int bytesRead = 0;
 
                  
 
                   while ((bytesRead = inputStream.read(buffer)) != -1) {
 
                       outputStram.write(buffer, 0, bytesRead);
 
                   }
 
                   outputStram.flush();
 
                   outputStram.close();
 
                   inputStream.close();
 
                   getFile().dispose();
 
                  
 
               } catch (FileNotFoundException fnfe) {
 
                   // TODO: Add catch code
 
                   fnfe.printStackTrace();
 
               } catch (IOException ioe) {
 
                   // TODO: Add catch code
 
                   ioe.printStackTrace();
 
               } 
 
        return null;
    }
    public void setFile(UploadedFile _File) {
 
           this._File = _File;
 
       }
 
    public UploadedFile getFile() {
 
          return _File;
 
      }
 
    public String getCurrentId() {
 
      BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
 
      AttributeBinding attr = (AttributeBinding)bindings.getControlBinding("Id"); 
 
      return  attr.getInputValue().toString().trim();
      
      
        
      
 
    }
    
        FacesMessage   message=new FacesMessage ("Success");
        message.setSeverity(FacesMessage.SEVERITY_INFO);
        FacesContext fc = FacesContext.getCurrentInstance(); 
        fc.addMessage(null, message);
        return null;
                            
               
 
}

 

ما الخطأ الذي يظهر بالضبط؟

بتاريخ:

السلام عليكم 

بعمل download ل file بالكود ده

    public String  downloadFileListener() throws IOException {
           HttpServletResponse response = getResponse();
           PrintWriter out = response.getWriter();  
          // ServletOutputStream out = response.getOutputStream();
          // response.setContentType("image/jpeg");
           response.setContentType("APPLICATION/OCTET-STREAM");
           String filename = it2.getValue().toString()+".jpg";  
           String filepath = "\\\\server_ip\\Certificate\\";   
           response.setContentType("APPLICATION/OCTET-STREAM");   
           response.setHeader("Content-Disposition","attachment; filename=\"" + filename + "\"");   
           FileInputStream fileInputStream = new FileInputStream(filepath + filename);  
                       
           int i;   
           while ((i=fileInputStream.read()) != -1) {  
           out.write(i);   
           }   
           fileInputStream.close();   
           out.close();   
           
        return null;
 

 

       }

 

 

 

 

 

 

 

 

بيطلعلى الerror ده ومبيخلينش اعمل اى حاجة فى الصفحة ازاى احل المشكلة دى

 

 

 

 

java.lang.IllegalStateException: Cannot forward a response that is already committed

احذف السطر            out.close();   

بتاريخ:

 

 

 

اذن ما الخطأ في ذلك

 

package view;

 

import java.io.File;

import java.io.FileNotFoundException;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.InputStream;

 

import javax.faces.application.FacesMessage;

 

import javax.faces.context.FacesContext;

 

import oracle.adf.model.BindingContext;

 

import oracle.binding.AttributeBinding;

import oracle.binding.BindingContainer;

 

import org.apache.myfaces.trinidad.model.UploadedFile;

 

public class UploadClass {

 

private UploadedFile _File;

public UploadClass() {

}

 

public String UploadProcess() {

// Add event code here...

 

String imagesFolder = "C:\\upload_id\\";

 

File myFile = new File(imagesFolder);

 

if ( !myFile.exists() ) { myFile.mkdir(); }

 

String newImageFile = imagesFolder + this.getCurrentId()+".rar";

 

try {

 

InputStream inputStream = getFile().getInputStream();

 

FileOutputStream outputStram = new FileOutputStream(newImageFile);

 

 

byte[] buffer = new byte[8192];

 

int bytesRead = 0;

 

 

 

while ((bytesRead = inputStream.read(buffer)) != -1) {

 

outputStram.write(buffer, 0, bytesRead);

 

}

 

outputStram.flush();

 

outputStram.close();

 

inputStream.close();

 

getFile().dispose();

 

 

 

} catch (FileNotFoundException fnfe) {

 

// TODO: Add catch code

 

fnfe.printStackTrace();

 

} catch (IOException ioe) {

 

// TODO: Add catch code

 

ioe.printStackTrace();

 

}

 

return null;

}

public void setFile(UploadedFile _File) {

 

this._File = _File;

 

}

 

public UploadedFile getFile() {

 

return _File;

 

}

 

public String getCurrentId() {

 

BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();

 

AttributeBinding attr = (AttributeBinding)bindings.getControlBinding("Id");

 

return attr.getInputValue().toString().trim();

 

 

 

 

 

}

 

FacesMessage message=new FacesMessage ("Success");

message.setSeverity(FacesMessage.SEVERITY_INFO);

FacesContext fc = FacesContext.getCurrentInstance();

fc.addMessage(null, message);

return null;

 

 

 

}

 

ما الخطأ الذي يظهر بالضبط؟
في السطر الاخير من الرساله لايفهم المتغيرfc مع اني معرفاه انه FacesContext
بتاريخ:

تأكد من import

بتاريخ:

import javax.faces.application.FacesMessage;

import javax.faces.context.FacesContext;

import oracle.adf.model.BindingContext;

هذه هي هل يوجد import لم اناديه

بتاريخ:

هل يوجد مكتبه يجب ان اضيفها اقصد libarary

بتاريخ:

 

السلام عليكم 

بعمل download ل file بالكود ده

    public String  downloadFileListener() throws IOException {
           HttpServletResponse response = getResponse();
           PrintWriter out = response.getWriter();  
          // ServletOutputStream out = response.getOutputStream();
          // response.setContentType("image/jpeg");
           response.setContentType("APPLICATION/OCTET-STREAM");
           String filename = it2.getValue().toString()+".jpg";  
           String filepath = "\\\\server_ip\\Certificate\\";   
           response.setContentType("APPLICATION/OCTET-STREAM");   
           response.setHeader("Content-Disposition","attachment; filename=\"" + filename + "\"");   
           FileInputStream fileInputStream = new FileInputStream(filepath + filename);  
                       
           int i;   
           while ((i=fileInputStream.read()) != -1) {  
           out.write(i);   
           }   
           fileInputStream.close();   
           out.close();   
           
        return null;
 

 

       }

 

 

 

 

 

 

 

 

بيطلعلى الerror ده ومبيخلينش اعمل اى حاجة فى الصفحة ازاى احل المشكلة دى

 

 

 

 

java.lang.IllegalStateException: Cannot forward a response that is already committed

احذف السطر            out.close();   

حذفت السطر يا بشمهندس ومازال نفس الخطا 

 

 

java.lang.IllegalStateException: Cannot forward a response that is already committed
at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:126)
at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:546)
at javax.faces.context.ExternalContextWrapper.dispatch(ExternalContextWrapper.java:93)
at javax.faces.context.ExternalContextWrapper.dispatch(ExternalContextWrapper.java:93)
at javax.faces.context.ExternalContextWrapper.dispatch(ExternalContextWrapper.java:93)
at oracle.adfinternal.view.faces.config.rich.RecordRequestAttributesDuringDispatch.dispatch(RecordRequestAttributesDuringDispatch.java:44)
at javax.faces.context.ExternalContextWrapper.dispatch(ExternalContextWrapper.java:93)
at javax.faces.context.ExternalContextWrapper.dispatch(ExternalContextWrapper.java:93)
at org.apache.myfaces.trinidadinternal.context.FacesContextFactoryImpl$OverrideDispatch.dispatch(FacesContextFactoryImpl.java:167)
at com.sun.faces.application.view.JspViewHandlingStrategy.executePageToBuildView(JspViewHandlingStrategy.java:364)
at com.sun.faces.application.view.JspViewHandlingStrategy.buildView(JspViewHandlingStrategy.java:154)
at org.apache.myfaces.trinidad.view.ViewDeclarationLanguageWrapper.buildView(ViewDeclarationLanguageWrapper.java:94)
at org.apache.myfaces.trinidad.view.ViewDeclarationLanguageWrapper.buildView(ViewDeclarationLanguageWrapper.java:94)
at org.apache.myfaces.trinidadinternal.application.ViewDeclarationLanguageFactoryImpl$ChangeApplyingVDLWrapper.buildView(ViewDeclarationLanguageFactoryImpl.java:322)
at oracle.adfinternal.view.faces.lifecycle.ResponseRenderManager._processViewDefinitionLanguage(ResponseRenderManager.java:105)
at oracle.adfinternal.view.faces.lifecycle.ResponseRenderManager.runRenderView(ResponseRenderManager.java:41)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._renderResponse(LifecycleImpl.java:1095)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:389)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:255)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)
بتاريخ:

import javax.faces.application.FacesMessage;

 

import javax.faces.context.FacesContext;

 

import oracle.adf.model.BindingContext;

 

هذه هي هل يوجد import لم اناديه

هذا يكفي

انضم إلى المناقشة

يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.

زائر
أضف رد على هذا الموضوع...

برجاء الإنتباه

بإستخدامك للموقع فأنت تتعهد بالموافقة على هذه البنود: سياسة الخصوصية

Account

Navigation

البحث

إعداد إشعارات المتصفح الفورية

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.