cfm: <cffile action="upload" fileField="Filedata" destination="#ExpandPath ('userUploads')#" nameConflict="makeUnique" /> C#.NET: string saveToFolder = "savedFiles" private void Page_Load(object sender, System.EventArgs e) { HttpFileCollection uploadedFiles = Request.Files; string Path = Server.MapPath(saveToFolder); for(int i = 0 ; i < uploadedFiles.Count ; i++) { HttpPostedFile F = uploadedFiles[i]; if(uploadedFiles[i] != null && F.ContentLength > 0) { string newName = F.FileName.Substring(F.FileName.LastIndexOf("\\") + 1); F.SaveAs(Path + "/" + newName); } } } php: <?php //path to storage $storage = 'userUploads'; //path name of file for storage $uploadfile = "$storage/" . basename( $_FILES['Filedata']['name'] ); //if the file is moved successfully if ( move_uploaded_file( $_FILES['Filedata']['tmp_name'] , $uploadfile ) ) { echo( '1 ' . $_FILES['Filedata']['name']); //file failed to move }else{ echo( '0'); } ?>
|
请发表评论