For uploading a file in sharepoint I use a webpart and an automatically generated form.
the tag for the upload file:
<input type="file" id="uploadfile" name="uploadfile" />
When I try to pick it up after posting, the file isn't accessible with the Request.Files attribute (Request.Files["uploadfile"]). (Request.Files looks like null on sharepoint)
Is there a solution in sharepoint without using the "runat=server" on the input tag?
To upload files to sharepoint you need to set enctype (enctype="multipart/form-data") on the form tag. Sharepoint doesn't add it when you use .
When using non ASP.NET controls, you can use 'this.Page.Form.Enctype = "multipart/form-data";' On Page_Load to add the enctype.
Is there a reason why you can't just use the ASP.NET FileUpload control? This will do all the hard work for you.
You can access a stream for the file via the FileContent property or as an array of bytes via the FileBytes property. Its filename is available via the FileName property.
Related
I have a web app using express.js and I've tried to embed a pdf into a .ejs file as follows:
embed src="mypdf.pdf" width="500" height="375" />
This gives me the following error when I load that page: Cannot GET /mypdf.pdf
What is the correct way to display a pdf embedded in an .ejs file using express.js (I only want the pdf to take up a portion of the page)?
You need to give the correct path for your pdf.
Check the similar line in your app.js
app.use(express.static(path.join(__dirname, 'public')));
Here public is the directory which you are telling express to consider for static resources and can be accessed directly with root path.
Now create a new folder in this public folder called docs or you can put pdf directly in the public folder
change embed tag as following
<embed src="/doc/mypdf.pdf" width="500" height="375" type="application/pdf">
if you put pdf directly in a public folder then change the path to /mypdf.pdf.
We have a Kentico project where we're using Azure Blob Storage for our media storage. When selecting a media file in a page, it stores the URL like this: www.ourhost.net/blobcontainer/kenticosite/media/medialibrary/picture.jpg
We are also using ImageProcessor.org. This only works when the image is requested through the host itself, so we need the media library selector to store the absolute URL like this: /blobcontainer/kenticosite/media/medialibrary/picture.jpg
How can this be done?
Thanks in advance. Nicolas.
I assume you are talking about Media selection form control, is that correct?
In this case the solution is for you to remove the protocol/domain from the absolute URL which is stored by the form control. You can do this by creating Custom macro since you are using Portal engine macros.
The purpose of the macro will simply be to take the absolute URL and make it a relative URL.
Instead of using this:
<img src="{% CurrentDocument["HeaderImage"] #%}" alt="{% CurrentDocument["Title"] #%}" />
You would call it like:
<img src="{% MyMacros.GetRelativeUrl(CurrentDocument["HeaderImage"]) #%}" alt="{% CurrentDocument["Title"] #%}" />
As you can see I'm using "MyMacros" namespace which is a best practise as it will enable you to keep all your macros organized. You can create custom namespaces as per this article
I am trying to add custom usercontrol in SharePoint 2013 HTML master page, but its not working and showing the message
SharePoint can't parse this file, most likely because of an incorrectly formatted SharePoint snippet. The markup at the following location is causing problems. Edit the markup manually to fix it, or replace it with a new snippet from the Snippet Gallery.
Invalid SharePoint markup at line 145. Please repair or recreate the markup
following is the code snippet for HTML master page.
<!--CS: Start Create Snippets From Custom ASP.NET Markup Snippet-->
<!--SPM:<%# Register Src="~/_controltemplates/15/SharePointProject1/UserControl1.ascx" TagPrefix="uc1" TagName="MyDepartmentControl" %>-->
<!--SPM:<uc1:MyDepartmentControl runat="server" id="MyDepartmentControl1" />-->
<!--CE: End Create Snippets From Custom ASP.NET Markup Snippet-->
Please help me how i can make it possible to add asp.net user-control in SharePoint 2013 HTML Master page.
Thanks in advance.
I just solved this problem.
The answer is; convert this line
<!--SPM:<%# Register Src="~/_controltemplates/15/SharePointProject1/UserControl1.ascx" TagPrefix="uc1" TagName="MyDepartmentControl" %>-->
to
<!--SPM:<%# Register TagPrefix="uc1" TagName="MyDepartmentControl" Src="~/_controltemplates/15/SharePointProject1/UserControl1.ascx" %>-->
Have fun..
I am using a third party to process transactions. They have an api that says XML content should submitted via an HTTP POST variable named “XML”.
I know how to create the xml, but not sure how to post it to their site. They have a destination url. Can you tell me how to do the Post to their site?
You need to carefully check. Usually you just post XML to an URL. However in this case (indicated by the variable name) it seems that a (typically only used for html forms) form post is needed.
The easiest way is to create a html form with that one field, something like this:
<form method="post" action="http://their url" name="payload">
<input type="hidden" id="XML" name="XML" />
</form>
Then you can fill the field with your XML and do a payload.submit()
Let us know how it goes
By default MOSS directs browser enabled InfoPath forms to the /_layouts/formserver.aspx page, with the query string parameters that define the form to display or edit. We have defined our own page (for a number of reasons) and would like to direct the forms in the form library there. The page can be hosted in that same _layouts folder, in a document library, it doesn't really matter.
Seems like there should be a linkeage (hopefully in a form of a configuration setting) that tells SharePoint where to direct the forms.
Thanks!
If you are using the SharePoint lists or form libraries to display the list of forms, you could add a jquery rewrite (in either a Custom Editor Web Part or Master Page) to look for links to the FormServer.aspx link.
<script type="text/javascript" src="~/_layouts/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
//Rewrite Form Links to Open in Custom Page
$("a[href*='/_layouts/FormServer.aspx']").each(function()
{
var formFileName = this.href.figureOutWhatFormAndParamsYouNeed()
var formServerUrl = 'https://server.example.com/_layouts/CustomPage.aspx'
this.href = formServerUrl
});
})
</script>
Have a look at the ServerFiles in the 12 Hive under 'Template\XML'. This has file extensions and a mapping to a redirect URL.
You can see there is a mapping for XSN and XML files in relation to InfoPath.
I haven't tried this and obviousily the normal caveats apply when altering files in the 12 Hive.