# Webdev upload fail

**URL:** <https://forum.inductiveautomation.com/t/webdev-upload-fail/54451>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [December 26, 2021, 3:47pm UTC](https://forum.inductiveautomation.com/t/webdev-upload-fail/54451 "2021-12-26T15:47:15Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![calimero100582](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/calimero100582/32/18630_2.png) [@calimero100582](https://forum.inductiveautomation.com/u/calimero100582)\
**Post date:** [March 21, 2023, 6:12pm UTC](https://forum.inductiveautomation.com/t/webdev-upload-fail/54451/8 "2023-03-21T18:12:42Z")

</div>

I know this is marked as solved, but if other stumble here and want some kind of solution, I parse the POST data as we cannot rely on servletRequest. Only thing is that I prepend date and time to the filename

```python
	from com.inductiveautomation.ignition.gateway import IgnitionGateway
	import os
	import re
    
	if request["servletRequest"].getContentType() and request["servletRequest"].getContentType().startswith("multipart/form-data"):
		today = system.date.now()
		backupTime = system.date.format(today, "yyyy-MM-dd'T'HH_mm_ss")
		dataDir = IgnitionGateway.get().getSystemManager().getDataDir()
		
		postdata = bytearray(request["postData"])
		
		separator = '\n'
		
		if postdata.index('\r\n') < postdata.index(separator):
			separator = '\r\n'
		
		boundary = postdata.split(separator, 1)[0]
		splitGroups = postdata.split(boundary)
		
		index = 0
		length = 0
		lenBoundary = len(boundary)
		lenSeparator = len(separator)
		
		for g in splitGroups:
			sub = g.split(separator * 2, 1)
			index = index + len(sub[0]) + 2 * (lenSeparator if len(sub) > 1 else 0)

			if "filename=\"" in sub[0] and len(sub) > 1:
				p = re.search("filename=\"([^\"]*)\"", sub[0])
				filepath = os.path.join(dataDir.getAbsolutePath(), "somesubfolder", "%s-%s" % (backupTime, p.group(1)))
				system.file.writeFile(filepath, request["postData"][index:index + len(sub[1]) - lenSeparator])
			
			if len(sub) > 1:
				index = index + len(sub[1])
			
			index = index + lenBoundary

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/webdev-upload-fail/54451)._
