ASIHTTPRequest 和 PHP;如何将多个图像流式传输到服务器
当我使用以下方法将一些图像发布到我的服务器时:
ASIFormDataRequest *request = [[ASIFormDataRequest alloc] initWithURL:url];
[request setShouldStreamPostDataFromDisk:YES];
[request setData:image withFileName:@"file(0)" andContentType:@"image/jpg" forKey:fileString];
[request setData:image withFileName:@"file(1)" andContentType:@"image/jpg" forKey:fileString];
[request setData:image withFileName:@"file(2)" andContentType:@"image/jpg" forKey:fileString];
[request startAsynchronous];
如何在 PHP 脚本中捕获它?
我正在
for($i = 0; $i<$imageCount; $i++){
$target_path = "files/";
$target_path = $target_path . basename( $_FILES['file($i)']['name']);
if(move_uploaded_file($_FILES['file($i)']['tmp_name'], $target_path)) {
echo "Image: ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "error uploading";
}
}
使用 imageCount 将图像总数发送到不同的变量中发布到服务器,但这每次都会引发上传错误。
When I POST some images to my server using:
ASIFormDataRequest *request = [[ASIFormDataRequest alloc] initWithURL:url];
[request setShouldStreamPostDataFromDisk:YES];
[request setData:image withFileName:@"file(0)" andContentType:@"image/jpg" forKey:fileString];
[request setData:image withFileName:@"file(1)" andContentType:@"image/jpg" forKey:fileString];
[request setData:image withFileName:@"file(2)" andContentType:@"image/jpg" forKey:fileString];
[request startAsynchronous];
How do I catch this in a PHP script?
I was doing
for($i = 0; $i<$imageCount; $i++){
$target_path = "files/";
$target_path = $target_path . basename( $_FILES['file($i)']['name']);
if(move_uploaded_file($_FILES['file($i)']['tmp_name'], $target_path)) {
echo "Image: ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "error uploading";
}
}
with imageCount the total number of images being sent POSTed in a different variable to the server, but this throws me upload errors each time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信错误与该文件有关。
I believe the error is with that files.
解决方案:
Solution: