<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Uploading a file through an html form in Developers</title>
    <link>https://communities.sas.com/t5/Developers/Uploading-a-file-through-an-html-form/m-p/203126#M4560</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The part for enctype="multipart/form-data" was exactly what was missing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;PA&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 11 Jun 2015 11:29:11 GMT</pubDate>
    <dc:creator>PAzevedo</dc:creator>
    <dc:date>2015-06-11T11:29:11Z</dc:date>
    <item>
      <title>Uploading a file through an html form</title>
      <link>https://communities.sas.com/t5/Developers/Uploading-a-file-through-an-html-form/m-p/203124#M4558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Greetings all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to create a form that allows users to upload a file from their local machines, which are actually virtual clients, to the SAS Server.&lt;/P&gt;&lt;P&gt;The structure of the application is basically a master Stored Process that calls one of two programs, depending on a macro variable named task.&lt;/P&gt;&lt;P&gt;The first program displays the form for the upload.&lt;/P&gt;&lt;P&gt;The second program actually is the one that should take care of uploading the file. At the moment is just a debug program because it's where I'm having problems on putting it to work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is I can't seem to access the file through the automatic macro variables _webin_* that should reference to information about the file that was selected in the upload form. I always get the warning message that the macro variables do not exist.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would appreciate if you look at my code bellow and tell me what is missing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Code for SP:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;%global task;&lt;/P&gt;&lt;P&gt;%let stppath=/Stored Processes/rmdb/Test1;&lt;/P&gt;&lt;P&gt;%macro main;&lt;/P&gt;&lt;P&gt;%if &amp;amp;task = %str() %then %do;&lt;BR /&gt; %include sasprog(nps_stp_show_upload_screen);&lt;BR /&gt;%end;&lt;/P&gt;&lt;P&gt;%else %do;&lt;BR /&gt; %include sasprog(nps_stp_upload_file);&lt;BR /&gt;%end;&lt;/P&gt;&lt;P&gt;%mend main;&lt;/P&gt;&lt;P&gt;%main;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Code for program nps_stp_show_upload_screen:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt; file _webout encoding="UTF-8";&lt;/P&gt;&lt;P&gt; put "&amp;lt;form method='post' action='do'&amp;gt;";&lt;/P&gt;&lt;P&gt; put "&amp;lt;input type='hidden' name='_program' value='&amp;amp;stppath.' /&amp;gt;";&lt;/P&gt;&lt;P&gt; put "&amp;lt;input type='hidden' name='task' value='upload_file' /&amp;gt;";&lt;/P&gt;&lt;P&gt; put '&amp;lt;table border="0" cellpadding="5"&amp;gt;';&lt;/P&gt;&lt;P&gt; put "&amp;lt;tr&amp;gt;";&lt;/P&gt;&lt;P&gt; put '&amp;lt;th&amp;gt;Choose a file to upload:&amp;lt;/th&amp;gt;';&lt;/P&gt;&lt;P&gt; put '&amp;lt;td&amp;gt;&amp;lt;input name="myfile" type="file" /&amp;gt;&amp;lt;/td&amp;gt;';&lt;/P&gt;&lt;P&gt;&amp;nbsp; put '&amp;lt;/tr&amp;gt;';&lt;/P&gt;&lt;P&gt; put '&amp;lt;tr&amp;gt;';&lt;/P&gt;&lt;P&gt;&amp;nbsp; put '&amp;lt;td colspan="2" align="center"&amp;gt;&amp;lt;input type="submit" value="OK" /&amp;gt;&amp;lt;/td&amp;gt;';&lt;/P&gt;&lt;P&gt; put '&amp;lt;/tr&amp;gt;';&lt;/P&gt;&lt;P&gt; put '&amp;lt;/table&amp;gt;';&lt;/P&gt;&lt;P&gt; put '&amp;lt;/form&amp;gt;';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Code for program nps_stp_upload_file:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt; file _webout encoding="UTF-8";&lt;BR /&gt; put "Fileref: &amp;amp;_WEBIN_FILEREF";&lt;BR /&gt; put "&amp;amp;_WEBIN_CONTENT_LENGTH";&lt;BR /&gt; put "&amp;amp;_WEBIN_CONTENT_TYPE ";&lt;BR /&gt; put "&amp;amp;_WEBIN_FILE_COUNT ";&lt;BR /&gt; put "&amp;amp;_WEBIN_FILEEXT ";&lt;BR /&gt; put "&amp;amp;_WEBIN_FILENAME ";&lt;BR /&gt; put "&amp;amp;_WEBIN_FILEREF ";&lt;BR /&gt; put "&amp;amp;_WEBIN_NAME ";&lt;BR /&gt; put "&amp;amp;_WEBIN_SASNAME ";&lt;BR /&gt; put "&amp;amp;_WEBIN_SASNAME_ORI ";&lt;BR /&gt; put "&amp;amp;_WEBIN_SASTYPE ";&lt;BR /&gt; put "&amp;amp;task";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt; infile &amp;amp;_webin_fileref;&lt;BR /&gt; input;&lt;BR /&gt; put _infile_;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first program runs without problems. When I submit the form I can see that the second program is being called, I have values for macro vaiables task and myfile but none for the auto macro variables _webin_*.&lt;/P&gt;&lt;P&gt;The first step throws several warnings because of the missing references. The second one an error because the infile statement cannot resolve to a fileref.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Help please!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;PA&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jun 2015 09:34:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Uploading-a-file-through-an-html-form/m-p/203124#M4558</guid>
      <dc:creator>PAzevedo</dc:creator>
      <dc:date>2015-06-11T09:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading a file through an html form</title>
      <link>https://communities.sas.com/t5/Developers/Uploading-a-file-through-an-html-form/m-p/203125#M4559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The stored process is set to deliver streaming results, right?&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is an example I have, based on Tricia Aanderud's excellent book 50 Keys to Learning Stored Processes (p 130.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I noticed below specifies enctype="multipart/form-data":&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&amp;nbsp; &amp;lt;FORM ACTION="&amp;amp;_URL" method="post" enctype="multipart/form-data"&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Maybe that is why your file isn't being uploaded??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data form;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format infile $char256.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile=resolve(_infile_);&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;&amp;lt;HTML&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;BODY&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;H3&amp;gt; Hi %sysfunc(scan(&amp;amp;_username,1)), Please select a file to Upload &amp;lt;/H3&amp;gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;FORM ACTION="&amp;amp;_URL" method="post" enctype="multipart/form-data"&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;INPUT TYPE="HIDDEN" NAME="_program" VALUE="&amp;amp;_program"&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;INPUT TYPE="HIDDEN" NAME="submit" VALUE="submitted"&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;table border="0" cellpadding="5"&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;INPUT TYPE="file" NAME="attach1" /&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;INPUT TYPE="submit" value="Upload"&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/table&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/FORM&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/BODY&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/HTML&amp;gt;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jun 2015 11:14:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Uploading-a-file-through-an-html-form/m-p/203125#M4559</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2015-06-11T11:14:43Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading a file through an html form</title>
      <link>https://communities.sas.com/t5/Developers/Uploading-a-file-through-an-html-form/m-p/203126#M4560</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The part for enctype="multipart/form-data" was exactly what was missing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;PA&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jun 2015 11:29:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Uploading-a-file-through-an-html-form/m-p/203126#M4560</guid>
      <dc:creator>PAzevedo</dc:creator>
      <dc:date>2015-06-11T11:29:11Z</dc:date>
    </item>
  </channel>
</rss>

