Reputation: 10936
I need to know it to correctly get filedata from POST dictionary.
I want to use Agile Uploader (resizes images on client side before upload on the server) in my project. It has process.php file as example of handling image on server. In that file:
$tmp_name = $_FILES["Filedata"]["file_name"]; // where "tmp_name" is file name
As Pyramid doesn't have FILES
dictionary, I supose I have to find image in POST
. But when I try to upload image POST
is empty...
So where it send that image and how to find it on server side?
HTML (most part of html code taken from their demo):
<form action="/test" method="post" id="singularDemo" enctype="multipart/form-data">
<div id="single"></div>
</form>
<a href="#" onClick="document.getElementById('agileUploaderSWF').submit();">Submit</a>
<script type="text/javascript">
$('#single').agileUploaderSingle({
submitRedirect:'',
formId:'singularDemo',
progressBarColor:'#3b5998',
flashVars:{
firebug:true,
form_action:'/test'
}
});
</script>
Python (Pyramid code), just for testing - simple view:
def test(request):
if request.method == 'POST':
pass
return {}
Thanks!
Upvotes: 1
Views: 847
Reputation: 36767
Since the $_FILES
global contains files submitted by a POST
request, you can access them using request.POST
:
# access the filename
filename = request.POST['Filedata'].filename
# access the actual file
input_file = request.POST['Filedata'].file
This is an exact equivalent of the PHP $_FILES
variable, so if it doesn't work, something else must be wrong.
The Pyramid cookbook has more information about file uploads.
Upvotes: 4