There is a system alert of (13, 'Permission denied'), how to solve that?

Posted by Semanty on Stack Overflow See other posts from Stack Overflow or by Semanty
Published on 2010-04-25T06:06:30Z Indexed on 2010/04/25 6:13 UTC
Read the original article Hit count: 160

Filed under:
|
|
def upload_file(request, step_id): 
    def handle_uploaded_file (file):
        current_step = Step.objects.get(pk=step_id)
        current_project = Project.objects.get(pk=current_step.project.pk)

        path = "%s/upload/file/%s/%s" % (settings.MEDIA_ROOT, current_project.project_no, current_step.name)
        if not os.path.exists (path): 
            os.makedirs(path)
        fd = open(path)
        for chunk in file.chunks():
            fd.write(chunk)
        fd.close()

    if request.method == 'POST':
        form = UploadFileForm(request.POST, request.FILES)
        if form.is_valid():
            handle_uploaded_file(request.FILES['file'])
            return HttpResponseRedirect('/success/url/')
    else:
        form = UploadFileForm()
    return render_to_response('projects/upload_file.html', {
                                                      'step_id': step_id,
                                                      'form': form,
                                                      })

© Stack Overflow or respective owner

Related posts about django

Related posts about fileupload