Dev控件的ASPxUploadControl怎么实现图片上传
1个回答
展开全部
" NotAllowedFileExtensionErrorText="不支持的图片格式!">
</ValidationSettings>
</dx:ASPxUploadControl>js://上传控件赋值给图片控件显示
function Uploader_OnFileUploadComplete(args) {
if (args.isValid) {
var imgSrc = decodeURI(args.callbackData);
ASPxClientImage.Cast('previewImage').SetImageUrl(imgSrc);
ASPxClientHiddenField.Cast("HiddenIds").Set("ImageUrl", imgSrc);}}function BeginUpload() {
var uploader = ASPxClientUploadControl.Cast('uploader');
var reg = /[@#\$%\^&\*]+/g;
if (uploader.GetText(0) != "") {
if (!reg.test(uploader.GetText(0))) {
uploader.Upload();} else {alert("文件名不能含有非法字符!");
uploader.ClearText();}}}后台://文件上传protected void FileToUpload_FileUploadComplete(object sender, DevExpress.Web.ASPxUploadControl.FileUploadCompleteEventArgs e){//删除旧相片
//保存新相片
e.CallbackData = SavePostedFile(e.UploadedFile);}private string SavePostedFile(UploadedFile uploadFile){//设置图片地址
const string UploadDirectory = "../../UploadFile/GuestPhoto/";
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询