Chào mừng đến với Diễn đàn lập trình - Cộng đồng lập trình.
Kết quả 1 đến 10 của 10
  1. #1
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Trích dẫn Gửi bởi zstar
    bạn cứ tạm thời để mode="off" xem nó lỗi ở dòng code nào
    từ đó sẽ biết cách khắc phục

    có thể permisson của Folder upload đang ở readonly

    regard !
    uhm mình có làm như bạn nói thì khi chạy lại nó báo lỗi ở dòng

    Mã:
     FileUpload1.SaveAs(Server.MapPath("http://HTK.com/hinhanh/" + FileUpload1.PostedFile.FileName));
    
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    
    Exception Details: System.Web.HttpException: http://HTK.com/hinhanh/tenfile is not a valid virtual path.
    
    Source File: c:\inetpub\vhosts\HTK.com\httpdocs\QT\GUI\Page.aspx.cs
    
    Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053 
    
    Lỗi này edit lại ntn để ko bị lỗi nữa hả các bạn. Giúp mình với!

  2. #2
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    ọc
    cái server mappath sao lại để đường dẫn thế kia

    mẫu :

    Mã:
    FileUpload1.SaveAs(Server.MapPath("~/Upload Files/" + FileUpload1.FileName));

  3. #3
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Trích dẫn Gửi bởi zstar
    ọc
    cái server mappath sao lại để đường dẫn thế kia

    mẫu :

    Mã:
    FileUpload1.SaveAs(Server.MapPath("~/Upload Files/" + FileUpload1.FileName));
    mình có thay đổi lại jong bạn nói
    Mã:
    FileUpload1.SaveAs(Server.MapPath("~/hinhanh/" + FileUpload1.PostedFile.FileName.ToString()));
    Nhưng vẫn bị lỗi sau :
    Mã:
    Access to the path 'C:\Inetpub\vhosts\HTK.com\httpdocs\hinhanh\phaohoa_Anh.jpg' is denied.
    
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    
    Exception Details: System.UnauthorizedAccessException: Access to the path 'C:\Inetpub\vhosts\HTK.com\httpdocs\hinhanh\phaohoa_Anh.jpg' is denied.
    
    ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.
    
    To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.
    Sau đó có vào choose "Properties" nhưng ko thấy Security tab. Để
    Click "Add" to add the appropriate user or group


    Phải làm sao đây bạn

  4. #4
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    vậy đúng như mình nói ở trên : permisson của Folder upload đang ở readonly
    bạn chỉnh lại read,write là được

  5. #5
    Trích dẫn Gửi bởi zstar
    vậy đúng như mình nói ở trên : permisson của Folder upload đang ở readonly
    bạn chỉnh lại read,write là được
    Mình cho permisson của Folder upload full lun rùi mà vẫn thế, đang nhờ chủ hosting xem lại thế nào. Cám ơn bạn đã nhiệt tình jup đỡ.Happy fun

  6. #6
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Hihihi chủ hosting khóa quyền đọc - ghi file sau khi mở đã chạy dc rùi.

    Thanks mọi người.

  7. #7
    Ngày tham gia
    Sep 2015
    Bài viết
    0

    Lỗi: Server Error in '/' Application khi upload file image trên hosting

    Tôi có coding như sau thì chạy tốt trên localhost nhưng khi up lên hosting và chạy kiểm tra lại thì lại xảy ra lỗi, code như sau:
    Mã:
     protected void btnUpload_Click(object sender, EventArgs e)
        {
            if (FileUpload1.HasFile)
            {
                
                lbLink.Text = "Copy chuỗi link này để chèn vào bài viết nếu cần";
    
        /hững dòng này để chạy trên hosting
    
        // http://HTK.com là đường dẫn website trên hosting và hinhanh là folder được lưu trên hosting
    
    
         txtUpload.Text = "http://HTK.com/hinhanh/" + FileUpload1.PostedFile.FileName.ToString();
         linkan.Text = "http://HTK.com/hinhanh/" + FileUpload1.PostedFile.FileName.ToString();
         FileUpload1.SaveAs(Server.MapPath("http://HTK.com/hinhanh/" + FileUpload1.PostedFile.FileName));           
    
    
                /hững dòng này chạy ở localhost
    
               // txtUpload.Text = "http://localhost:56143/MyWebSite/hinhanh/" + FileUpload1.FileName;
               // linkan.Text = "../../FileUpload/" + FileUpload1.PostedFile.FileName;
               //FileUpload1.SaveAs(Server.MapPath("../../hinhanh/" + FileUpload1.PostedFile.FileName));
                        }
            else MessageBox.Show("mời chọn file ảnh");           
        }
    Hình ảnh lỗi khi thực hiện tại sự kiện trên hosting

    Mã:
    Server Error in '/' Application.
    Runtime Error
    Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
    
    Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
    
    <!-- Web.Config Configuration File -->
    
    <configuration>
        <system.web>
            <customErrors mode="Off"/>
        </system.web>
    </configuration>
    
    
    Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.
    
    <!-- Web.Config Configuration File -->
    
    <configuration>
        <system.web>
            <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
        </system.web>
    </configuration>
    Bạn nào đã từng gặp lỗi giống như mình hoặc biết cách giải quyết xin cho hướng dẫn
    Chân thành cám ơn

  8. #8
    copy thằng này bỏ vô cofig

    <configuration>
    <system.web>
    <customErrors mode="Off"/>
    </system.web>
    </configuration>

  9. #9
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Trích dẫn Gửi bởi nvluong_it
    copy thằng này bỏ vô cofig

    <configuration>
    <system.web>
    <customErrors mode="Off"/>
    </system.web>
    </configuration>
    Ủa vậy bạn ui trong web.config mình cũng có dòng này thì sao
    Mã:
    <customErrors mode="On" defaultRedirect="ErrorPage.aspx">
          <error statusCode="403" redirect="NoAccess.htm"/>
          <error statusCode="404" redirect="FileNotFound.htm"/>
        </customErrors>
    Vì mình muốn khi có lỗi xảy ra sẽ chạy đến page ErrorPage.aspx để người sử dụng nhìn đỡ sợ
    [IMG]images/smilies/smile.png[/IMG]) ấy mà

  10. #10
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    bạn cứ tạm thời để mode="off" xem nó lỗi ở dòng code nào
    từ đó sẽ biết cách khắc phục

    có thể permisson của Folder upload đang ở readonly

    regard !

 

 

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  •