我想在我的Intranet页面上实现一个简单的文件上传,尽可能小的设置.
这是我的HTML部分:
<input id="sortpicture" type="file" name="sortpic" />
<button id="upload">Upload</button>
Run Code Online (Sandbox Code Playgroud)
这是我的JS jquery脚本:
$("#upload").on("click", function() {
var file_data = $("#sortpicture").prop("files")[0];
var form_data = new FormData();
form_data.append("file", file_data);
alert(form_data);
$.ajax({
url: "/uploads",
dataType: 'script',
cache: false,
contentType: false,
processData: false,
data: form_data,
type: 'post',
success: function(){
alert("works");
}
});
});
Run Code Online (Sandbox Code Playgroud)
在网站的根目录中有一个名为"uploads"的文件夹,具有"users"和"IIS_users"的更改权限.
当我选择具有文件格式的文件并按下上传按钮时,第一个警报返回"[object FormData]".第二个警报没有被调用,"uploads"文件夹也是空的!?
有人可以帮助我找出错误吗?
下一步应该是,用服务器端生成的名称重命名文件.也许有人可以给我一个解决方案.
我从使用coreData对象填充的tableView中删除行时遇到一些问题.
试着这样做:
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath*)indexPath{
if (editingStyle == UITableViewCellEditingStyleDelete) {
[self.tableView beginUpdates];
NSManagedObject *managedObject = [self.fetchedResultsController objectAtIndexPath:indexPath];
NSLog(@"Deleting (%@)", [managedObject valueForKey:@"original_title"]);
[self.managedObjectContext deleteObject:managedObject];
[self.managedObjectContext save:nil];
[self performFetch];
[self.tableView endUpdates];
}
}
Run Code Online (Sandbox Code Playgroud)
因此,当我单击"删除"按钮时,应用程序崩溃并显示以下日志:
*** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-2872.3/UITableView.m:1254
2013-08-13 18:39:17.624 RR_proto[1076:a0b] *** Terminating app due to uncaught exception
'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of sections.
The number of sections contained in the table view after the update (1) must be equal
to the number of sections contained …Run Code Online (Sandbox Code Playgroud) ajax ×1
core-data ×1
delete-row ×1
ios ×1
javascript ×1
jquery ×1
objective-c ×1
php ×1
tableview ×1
upload ×1