最短的无组件上传代码(仅9行)

我研究了一下无组件上传,并作出了一个最简单可行的方法
----用9行代码真正实现无组件上传,怎么说来花了才半天就写了9行代码算是有点效率和成果。
于是就写了这篇文章。



formSize=Request.TotalBytes()
formData=Request.BinaryRead(formSize)
DataHeader=LeftB(formData,InStrB(formData,Chrb(13)&Chrb(10)))
strFileData=MIDB(formData,LenB(DataHeader),LenB(formData)-LenB(DataHeader)*2-3)
HeaderPos2=InStrB(strFileData,ChrB(AscB("-"))&ChrB(AscB("T"))&ChrB(AscB("y"))&ChrB(AscB("p"))&C

hrB(AscB("e")))
HeaderPos3=InStrB(HeaderPos2,strFileData,Chrb(13))
DataHeader2=LeftB(strFileData,HeaderPos3+4)
strFileData=MIDB(strFileData,LenB(DataHeader2),LenB(strFileData))
Response.binaryWrite(strFileData)







DataHeader--文件头
strFileData--去处文件头后的数据,最后的输出值
HeaderPos2--Content-Type:的位置
HeaderPos3--例如:Content-Type:image/gif的位置
DataHeader2--整个前面的文件头

思想:
1。先直接去掉文件头和尾(例如-----------------------------7d230d1f940277)
2。跳过前面所有信息直接查找Content-Type:image/gif
3。提取有用的信息和字段
4。数据都提出来了至于怎么保存就简单了。至于用FSO或Adodb.Stream就随你了。

问题:
有人可能会讲一个表单不可能只有一个file
这样的话你的数据就不能用这么简单的办法正常提取了
其实也好办你把他们分开做不就就完了:)


下面是完整实例

uup.htm
<html>
<a  href="http://www.cgfront.com">www.cgfront.com</a>
<form  name="loadfromfile"  action="uup.asp"  method="post"  enctype="multipart/form-data">
  <input  type="submit"  name="submit"  value="OK">
        <input  type="file"  name="loadfromfile"  style="width:400"    value="">
</form>
</html>

uup.asp
<%
formSize=Request.TotalBytes()
formData=Request.BinaryRead(formSize)
DataHeader=LeftB(formData,InStrB(formData,Chrb(13)&Chrb(10)))
strFileData=MIDB(formData,LenB(DataHeader),LenB(formData)-LenB(DataHeader)*2-3)
HeaderPos2=InStrB(strFileData,ChrB(AscB("-"))&ChrB(AscB("T"))&ChrB(AscB("y"))&ChrB(AscB("p"))&C

hrB(AscB("e")))
HeaderPos3=InStrB(HeaderPos2,strFileData,Chrb(13))
DataHeader2=LeftB(strFileData,HeaderPos3+4)
strFileData=MIDB(strFileData,LenB(DataHeader2),LenB(strFileData))
Response.binaryWrite(strFileData)
%>




如果你的键盘上ctrl+C  +V键都已经被你按坏了的话,没关系我还给大家提供了相应的测试地点

http://www.cgfront.com/up/uup.htm

最后希望大家多多指教。


作者:Leonard
以下是使用Floyd算法在MATLAB中求解最短路径的完整代码示例,它适用于无向图和有向图[^1]: ```matlab % 输入顶点数和边的权重(假设为无向图) numVertices = input('Enter the number of vertices: '); edgeWeights = input('Enter the edge weights (as a matrix where row i and column j represents weight from i to j): '); % 检查输入的合法性 if size(edgeWeights, 1) ~= numVertices || size(edgeWeights, 2) ~= numVertices error('Invalid edge weights matrix.'); end % 初始化邻接矩阵和零矩阵用于存储路径 adjMatrix = sparse(1:numVertices, 1:numVertices, edgeWeights, numVertices, numVertices); pathMatrix = inf(numVertices, numVertices); % 使用无穷大初始化路径矩阵 % Floyd-Warshall算法 for k = 1:numVertices for i = 1:numVertices for j = 1:numVertices pathMatrix(i,j) = min(pathMatrix(i,j), adjMatrix(i,k) + adjMatrix(k,j)); end end end % 输出结果 disp('Shortest paths:'); disp(pathMatrix); % 用户可以通过命令窗口交互查询特定两点的最短路径 fprintf('Enter the source vertex (s) and destination vertex (e): '); s = input('s = '); e = input('e = '); % 获取指定两点的最短路径 shortestPath = pathMatrix(s, e); shortestLength = shortestPath; fprintf('The shortest path from vertex %d to vertex %d is %d with length %.2f.\n', s, e, shortestPath, shortestLength); ``` 要运代码,首先确保在MATLAB中创建一个名为`canshuo.m`的文件,并将上述代码复制进去。然后按照说明在命令窗口中输入节点数、边权重矩阵以及查询的起始点和结束点。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值