Home/Support/Support Forum/http file upload problem
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

http file upload problem

0 votes
can't find any good explanation to file upload example inside digi net os
some one has a link to a guide?
asked Oct 28, 2013 in NET+OS by gavello New to the Community (16 points)
reshown Nov 7, 2013 by gavello

Please log in or register to answer this question.

3 Answers

0 votes
Hello could you be a little more specific please?

What version of NET+OS?
Are you looking for something more than the example application that demonstrates uploading files to the file system via a web page?

Maybe a little about what you are trying to accomplish.

BTW are you looking to upload a file through a normal http page (compiled through PBUILDER) or a CGI page?
answered Oct 28, 2013 by dakotas_dad Veteran of the Digi Community (694 points)
Hi
I'm using the latest NET+OS release
I've tried the CGI way but you told me that it is not possible so i've tried to understand what was going on inside the examples code provided in NET+OS. (HTTP File System Sample)

Without success... i need to implement an html page for file upload to FLASH0/TWDL

I do not really understand what the upload.html stub functions do.
I do not even get where the file data goes when the upload button is pressed.
0 votes
Hi
I'm using the latest NET+OS release
I've tried the CGI way but you told me that it is not possible so i've tried to understand what was going on inside the examples code provided in NET+OS. (HTTP File System Sample)

Without success... i need to implement an html page for file upload to FLASH0/TWDL

I do not really understand what the upload.html stub functions do.
I do not even get where the file data goes when the upload button is pressed.
answered Oct 30, 2013 by gavello New to the Community (16 points)
The web system on NET+OS uses a file entitled file.c as its (the web server) interface to the file system. Your best bet would be to take a look at file.c and what it is doing when you access files (into and out of the web server).

   A lot of the APIs in file.c are actually callbacks that the web server calls when it is tasked with doing something involving a file access operation.
thanks i'll give a try
0 votes
Code:
<!-- RpPageHeader Rpurl="/upload.htm" RpFunctionPtr=upload_init RpAccess=Realm1 RpAccess=Realm2 --> <!-- RpEnd --> <html> <head> <title>File Upload</title> </head> <body> <p> <center><h2>File Upload</h2> </center> <!-- RpFormHeader Enctype=MULTIPART/FORM-DATA RpFunctionPtr=upload_submit RpAccess=Realm1 RpAccess=Realm2 --> <FORM ENCTYPE="multipart/form-data" METHOD="POST" ACTION="/Forms/FileUpload"> <!-- RpEnd --> <p> Netscape > 3.0 and Microsoft > 4.0 support HTTP file upload capabilities. If your browser supports this capability, you will see a browse button that can be used to select the file to upload.</p> <table border=0> <tr><th align=left>File to Upload</th> <td><INPUT TYPE="FILE" NAME="file" SIZE="32" MAXLENGTH="32"> </td> <td> <!-- RpFormSingleSelect NAME="SelectUploadDirectory" SIZE=1 RpGetType=Complex RpGetPtr=getSelectedDir RpSetType=Complex RpSetPtr=setSelectedDir --> <SELECT NAME="SelectUploadDirectory" SIZE="1"> <!-- RpEnd --> <!-- RpSingleSelectOption VALUE="Item 1" RpItemNumber=1 --> <OPTION SELECTED>Item 1 <!-- RpEnd --> <!-- RpSingleSelectOption VALUE="Item 2" RpItemNumber=2 --> <OPTION>Item 2 <!-- RpEnd --> <!-- RpSingleSelectOption VALUE="Item 3" RpItemNumber=3 --> <OPTION>Item 3 <!-- RpEnd --> <!-- RpSingleSelectOption VALUE="Item 4" RpItemNumber=4 --> <OPTION>Item 4 <!-- RpEnd --> <!-- RpSingleSelectOption VALUE="Item 5" RpItemNumber=5 --> <OPTION>Item 5 <!-- RpEnd --> <!-- RpEndSelect --> </SELECT> <!-- RpEnd -->
Code:
/* Created with PageBuilder version 4.04 on Tue Nov 5 15:17:39 2013 */ #include "AsExtern.h" #include "file.h" #include "fileinit.h" #include "string.h" #include "fs_api.h" #if RomPagerServer /* ************************************** */ /* * Built from "html\upload.htm" * */ /* ************************************** */ extern rpOneOfSeveral getSelectedDir(void *theTaskDataPtr, char *theNamePtr, Signed16Ptr theIndexValuesPtr); rpOneOfSeveral getSelectedDir(void *theTaskDataPtr, char *theNamePtr, Signed16Ptr theIndexValuesPtr) { rpOneOfSeveral theResult; return theResult; } extern void setSelectedDir(void *theTaskDataPtr, rpOneOfSeveral theValue, char *theNamePtr, Signed16Ptr theIndexValuesPtr); void setSelectedDir(void *theTaskDataPtr, rpOneOfSeveral theValue, char *theNamePtr, Signed16Ptr theIndexValuesPtr) { if (theValue == 4) { RpHSSetCurrentDirectory(RpGetCurrentConnection(theTaskDataPtr), "FLASH0/APP"); }else{ RpHSSetCurrentDirectory(RpGetCurrentConnection(theTaskDataPtr), FS_FLASH_VOLUME_ROOT_DIR); } return; } extern void upload_submit(void *theTaskDataPtr, Signed16Ptr theIndexValuesPtr); void upload_submit(void *theTaskDataPtr, Signed16Ptr theIndexValuesPtr) { int errorStatus; int theFileNumber; theFileNumber = RpGetCurrentConnection(theTaskDataPtr); RpHSGetErrorStatus(theFileNumber, &errorStatus); if (errorStatus == NAFS_SUCCESS) { printf("File Upload Success\n"); } else { printf("File Upload Error\n"); printf("RpHSGetErrorStatus(%d, %d)\n", theFileNumber, errorStatus); } return; } extern void upload_init(void *theTaskDataPtr, Signed16Ptr theIndexValuesPtr); void upload_init(void *theTaskDataPtr, Signed16Ptr theIndexValuesPtr) { return; } #endif /* RomPagerServer */

Inside setSelectedDir I try to set the desired upload directory but I've noticed the function is called only after the upload is completed.

So the destination directory is always wrong and the first execution because no destination is set produce an error
answered Nov 5, 2013 by gavello New to the Community (16 points)
edited Nov 6, 2013 by gavello
...