如何用asp添加文件夹-花衣燕子别来

如何用asp添加文件夹-花衣燕子别来,第1张

分类: 电脑/网络 >>程序设计 >>其他编程语言

问题描述:

我想做个多用户相册BLOG系统

语言我只会ASP

用户上传的照片我想把他们分别存在/upload/用户名的文件夹

也就是说每个用户上传的图片都在他自己的文件夹里

现在我的思路就是用户申请注册的时候,可不可以用asp语句在upload中建立一个以用户名命名的文件夹?

要有相关的代码语句

谢谢

解析:

使用FSO新建文件夹

Dim objFSO

Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

path = Server.MapPath("\upload\user")

If objFSO.FolderExists(path) Then

Response.Write path&"文件夹已经存在!"

Else

objFSO.CreateFolder(path)

Response.Write "新建文件夹的位置为"&path

End If

Set objFSO = Nothing

花衣燕子这下出名了

1、拖一个文本框

2、拖一个按钮

3、按钮事件处理程序中使用文本框输入的值作为名称创建文件夹;

4、引用System.IO,使用代码

using System

using System.IO

class Test

{

publicstaticvoid Main()

{

// Specify the directory you want to manipulate.

string path = @"c:\MyDir"

try

{

// Determine whether the directory exists.if (Directory.Exists(path))

{

Console.WriteLine("That path exists already.")

return

}

// Try to create the directory.

DirectoryInfo di = Directory.CreateDirectory(path)

Console.WriteLine("The directory was created successfully at {0}.", Directory.GetCreationTime(path))

// Delete the directory.

di.Delete()

Console.WriteLine("The directory was deleted successfully.")

}

catch (Exception e)

{

Console.WriteLine("The process failed: {0}", e.ToString())

}

finally {}

}

}

下面是表单代码:

<form id="form1" name="form1" method="post" action="folder.asp">

请指定<span class="STYLE3">文件位置和文件名: <input type="text" name="createflie">

<input type="submit" name="Submit" value="确定" />

</form>

提交到folder.asp

<%

folder = request("createflie")

set fso = server.CreateObject("scripting.filesystemobject")

fso.createfolder(server.MapPath(".\"&folder&""))

response.Write("文件夹创建成功")

%>

经测试可以创建成功


欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/tougao/8018968.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-12
下一篇 2023-04-12

发表评论

登录后才能评论

评论列表(0条)

保存