I need to upload a PDF
in grails
I have looked in texts and online. This is what I have so far in my controller
def upload = {
def f = request.getFile('myFile')
if(!f.empty) {
f.transferTo( new File('/some/local/dir/myfile.txt') )
response.sendError(200,'Done');
} else {
flash.message = 'file cannot be empty'
render(view:'uploadForm')
}
}
In the view I have this in the _forms view
<g: uploadForm action="upload">
<input type="file" name="myFile"/>
<input type= "submit" value="Upload"/>
</g: uploadForm>
When I go to the create page to I get an error.
I get this error Grails tag [g:] was not closed. Stacktrace follows:
Message: Error processing GroovyPageView: Grails tag [g:] was not closed
Line | Method
->> 461 | doFilter in \grails-app\views\report\create.gsp
Caused by GrailsTagException: Grails tag [g:] was not closed
->> 36 | doCall in C:/Users/Owner/Desktop/grails-app/views/report/create.gsp
Any suggestion on how to clear the error? When I delete the addition to the _forms view the error goes. I can't see the unclosed tag
Full gsp as asked for
<div class="fieldcontain ${hasErrors(bean: reportInstance, field: 'location', 'error')} required">
<label for="location">
<g:message code="report.location.label" default="Location" />
<span class="required-indicator">*</span>
</label>
<g:select id="location" name="location.id" from="${lc.Location.list()}" optionKey="id" required="" value="${reportInstance?.location?.id}" class="many-to-one"/>
</div>
<div class="fieldcontain ${hasErrors(bean: reportInstance, field: 'published', 'error')} required">
<label for="published">
<g:message code="report.published.label" default="Published" />
<span class="required-indicator">*</span>
</label>
<g:datePicker name="published" precision="day" value="${reportInstance?.published}" />
</div>
<div class="fieldcontain ${hasErrors(bean: reportInstance, field: 'title', 'error')} ">
<label for="title">
<g:message code="report.title.label" default="Title" />
</label>
<g:textField name="title" value="${reportInstance?.title}"/>
</div>
<div class="fieldcontain ${hasErrors(bean: reportInstance, field: 'myFile', 'error')} ">
<label for="myFile">
<g:uploadForm action="upload"/>
<input type="file" name="myFile"/>
<input type= "submit" value="Upload"/>
</g:uploadForm>
</label>
</div>
Remove /
from
<g:uploadForm action="upload"/>
This should be
<g:uploadForm action="upload">
....
</g:uploadForm>