problème avec le controle FileUpload
salut,
je veux utiliser le controle serveur fileupload, j'ai crée un repertoire nommé upload sous le repertoire de mon siteweb, j'ai suit l'arlicle trouvé sous msdn
http://msdn.microsoft.com/fr-fr/library/aa479405.aspx
mais il m'affiche l'erreur suivante:
Code:
ERROR: The SaveAs method is configured to require a rooted path, and the path '~\SkarkaWebSite\upload\Couleurs des pages 809.doc' is not rooted.
le voila le code aspx:
Code:
1 2 3 4 5 6 7
| <div>
<asp:FileUpload ID="FileUpload1" runat="server" /><br />
<br />
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click"
Text="Upload File" /> <br />
<br />
<asp:Label ID="Label4" runat="server"></asp:Label></div> |
et le code vb:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| Protected Sub Button2_Click(ByVal sender As Object, _
ByVal e As System.EventArgs)
If FileUpload1.HasFile Then
Try
FileUpload1.SaveAs("~\SkarkaWebSite\upload\" & _
FileUpload1.FileName)
Label1.Text = "File name: " & _
FileUpload1.PostedFile.FileName & "<br>" & _
"File Size: " & _
FileUpload1.PostedFile.ContentLength & " kb<br>" & _
"Content type: " & _
FileUpload1.PostedFile.ContentType
Catch ex As Exception
Label1.Text = "ERROR: " & ex.Message.ToString()
End Try
Else
Label1.Text = "You have not specified a file."
End If
End Sub |
merci d'avance