如何使用aasp.net上传文件控制上传文件,并在控制te文件大小后将文件路径存储在sql server表中 [英] how to upload file using aasp.net upload file control and storing the path of the file in a sql server table after controling the size of te file

查看:73
本文介绍了如何使用aasp.net上传文件控制上传文件,并在控制te文件大小后将文件路径存储在sql server表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好我是Dotnet的新手我正在使用asp.net和vb.net开发一个web应用程序,我正在尝试在asp.net中添加上传控件以上传所有不同的文件



我花了太多天看网,最后找到了很多代码,但没有一个人有我想要的答案。



有人可以帮助我并向我解释如何在存储之前首先控制文件的大小,然后如何将其上传到服务器并存储路径我的数据库表。

Hello everyone i am new in Dotnet i am working on a web application using asp.net and vb.net and i am trying to add the upload control in asp.net in order to upload all the diffrent files

I spend too many days looking in the net and i end up finding to many codes but no one of them had the answer that i am looking for .

Can plz someone helps me and explain to me how to control first the size of the files before storing it and then how to upload it in server and store the path in my database table .

推荐答案

控制服务器中的文件大小和文件名写下事件中的代码,同时保存



To control file size and file name in server write below code in event while saving

IF FileUploadControl.PostedFile.ContentLength  < 1024'<<your condition size should be in bytes>>
 Dim strserverpath as string
 Dim strfilename as string
 strserverpath = "" 'server path
 strfilename = Path.GetFileName(FileUploadControl.FileName)
 strfilename = strserverpath & strfilename
 FileUploadControl.SaveAs(strfilename)
 'save strfilename in database
END IF


这篇关于如何使用aasp.net上传文件控制上传文件,并在控制te文件大小后将文件路径存储在sql server表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆