Upload photos?

Feb 21, 2010 at 12:09 AM

The metaweblog should support fileupload but when I try to upload a picture I get a error message telling me that my blog isn't supporting fileuploading.

I have this options added to my manifest.xml

 

	<options>
		<clientType>MetaWeblog</clientType>
		<supportsEmbeds>Yes</supportsEmbeds>
		<supportsFileUpload>Yes</supportsFileUpload>
		<supportsKeywords>Yes</supportsKeywords>
		<supportsCategories>Yes</supportsCategories>
		<supportsNewCategories>Yes</supportsNewCategories>
		<supportsNewCategoriesInline>Yes</supportsNewCategoriesInline>
		<supportsCommentPolicy>Yes</supportsCommentPolicy>
		<supportsSlug>No</supportsSlug>
		<supportsExcerpt>No</supportsExcerpt>
		<supportsPages>No</supportsPages>
		<supportsPageParent>No</supportsPageParent>
		<supportsPostAsDraft>Yes</supportsPostAsDraft>
		<supportsCustomDate>Yes</supportsCustomDate>
	</options>

 

 

Feb 21, 2010 at 12:18 AM

Ah now I got it. The code was sending an exception so the function never returned anything. But now it returns an empty string so atleast I dont get the error no more.

But how do I get info about the image width and height that the use can change from WLM?

When an image is added it gets handled that can be used to change the size of the image but If I want to use this information to resize the image before I save it, how do i retrive it?

Coordinator
Feb 21, 2010 at 9:11 AM

when your user adds an image to wlw he can resize it in wlw, then wlw makes two uploads (original and thumbnail). If you really wish you can resize your file when you save it on your server, you should be able to check for dimensions when file is saved, not sure how, i never tried that.

Feb 21, 2010 at 10:33 AM

ah right. I just noticed that. But how do I get access to the file and save it on my webserver?

Do i need to use the "File.WriteAllBytes" method?

Coordinator
Feb 21, 2010 at 11:06 AM

you can save it however you like it, i used file.writeallbytes because i find it most convenient

Feb 21, 2010 at 11:15 AM

Ah yeah but how do I use that method? I tried it but I dont really know how to use it.

Coordinator
Feb 21, 2010 at 11:21 AM

            string fileUrl = HttpContext.Current.Request.PhysicalApplicationPath + @"somedir\filename.jpg";
            File.WriteAllBytes(fileUrl, mediaObject.bits);

Feb 21, 2010 at 12:53 PM
Edited Feb 21, 2010 at 1:07 PM

I guess that saves the file in a folder in WLM but how do I then save it on my webserver?

Thanks for you help.

 

 

edit: I tried your code but it didnt work. What is the @ character doing? Do i need to specify a folder that exists or?

Feb 21, 2010 at 1:10 PM

Just so I could see what PhysicalApplicationPath looked like I used this code for sending it to a string:

 

string testing = HttpContext.Current.Request.PhysicalApplicationPath.ToString();

But with this line i the code the WLW stopped the saving process giving me the error saying the blog doesnt support embedding.

 

Coordinator
Feb 21, 2010 at 1:50 PM

my code saves file to your server.

this error you get might be because embeding is not approved in wlwmanifest ?

Feb 21, 2010 at 7:17 PM

oh... lol sorry... I thought that the "applicationdir" was the local directory of WLW. :P

Then I get it. :)

supportsEmbeds is enabled and that code isn't saving anything it just puts a value inside the string "testing" so my guess is it comes from something else beside the options of the manifest file.

You can see in my first post what options I have enabled.

Coordinator
Feb 22, 2010 at 6:19 AM

@ sing is for literal string definition.

is there any error when you upload images?