This is done by an app that displays a html
form within a webview
.
In the form I have the following fields:
- Title
- Description
- Image (input file)
If I do not add an image, everything is fine, but if I select an image through the input, I only reload the form, so it erases the previously entered data.
My html:
<div class="container">
<form role="form" id="commentForm" action="/new" method="POST" enctype="multipart/form-data">
<div class="form-group">
<label>Titulo</label>
<input type="text" class="form-control" name="titulo" required="">
</div>
<div class="form-group">
<label>Descripcion</label>
<textarea name="desc" style="height: 100px; width: 100%; resize: none;" required=""></textarea>
</div>
<div class="form-group">
<label>Imagen</label>
<input type="file" class="form-control" name="nombre_archivo" >
</div>
<button class="btn btn-success" type="submit">Crear Oferta</button>
</form>
</div>
My swift code:
class NavegadorViewController: UIViewController, UIWebViewDelegate {
var url: String?
@IBOutlet weak var webView: UIWebView!
@IBOutlet weak var carga: UIActivityIndicatorView!
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.setNavigationBarHidden(false, animated: true)
self.webView.delegate = self
carga.startAnimating()
}
func webViewDidStartLoad(webView: UIWebView) {
carga.startAnimating()
}
func webViewDidFinishLoad(webView: UIWebView){
carga.stopAnimating()
carga.hidden = true
}
override func viewDidAppear(animated: Bool) {
let url:NSURL? = NSURL(string: self.url!)
if let actualUrl = url {
let urlRequest:NSURLRequest = NSURLRequest(URL: actualUrl)
self.webView.loadRequest(urlRequest)
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func dismissViewControllerAnimated(flag: Bool, completion: (() -> Void)?) {
if self.presentedViewController != nil {
super.dismissViewControllerAnimated(flag, completion: completion)
}
}
}
What could be the problem ?? I have to change something from html
or swift ??