PHP backend version?

Dec 3, 2008 at 2:56 PM
Is there a PHP backend version for this?
Any tips or suggestions on writing one?

I have a PHP multi file upload, but it is slow (uses uploadStringAsync), does not provide progress indicator and the interface is poor.

Thanks
Tom
Coordinator
Dec 3, 2008 at 10:54 PM

I've crated an example using PHP.  You can download it from the releases tab.

Darick

Dec 7, 2008 at 1:34 AM
Thanks.

I was able to get the control into my Silverlight app and upload files to a Linux server using your PHP script (with one small change).

Here are a couple of observations:

1. The individual progress bar indicators go to 100% as soon as the that file transfer starts.  The combined progress increments by file size as well.

2. The transfers for multiple files are sequential instead of concurrent, is that the way it's supposed to be?  It would be better if at least a few are concurrent.

3. When I used your application, the same files where uploaded much faster then when I used your control with your PHP backend.

4. In the xaml where i have the control and also in your project I get this error:

Error 66 Unknown attribute Name on element FileUploadControl. [Line: 74 Position: 49] 

 I add the control byy adding the DC.FileUpload.dll as a reference

then adding this to my xaml:

 

xmlns:c="clr-namespace:DC.FileUpload;assembly=DC.FileUpload"

and also this

 

<

 

c:FileUploadControl x:Name="uploadControl" Width="500" Height="500" />

5. I needed to change one line in the php file probably because that line is for Windows systems:

$filePath = $filename;
 instead of:
$filePath = "c:/www/inetpub..." . $filename;
The files still made it to the server, but the filenames have the whole path in it and I can't even delete them now through ftp.

Question: is the client side resize on or off and what does it really do?



Thanks
Tom

Dec 7, 2008 at 2:15 PM
Darick,

Never mind about #2 above i.e: 2. The transfers for multiple files are sequential instead of concurrent, is that the way it's supposed to be?  It would be better if at least a few are concurrent.

I set the MaxConcurrentUploads field in the control and it works.

I do have one other observation which is important to me and I may need to add it myself unless you are going to, and that is: DestinationDirectory

I need to upload files to many different directories (only one directory per upload), and I would like to have only one copy of the PHP script and then tell the PHP script where to put the files.

So the only 2 things I need to use this control in my app are:
1. Progress bar that shows percentages other than 0 and 100
2. Ability to specify DestinationDirectory.

BTW, I saw the fields: MaximumUpload and MaximumTotalUpload, are those meant to limit the maximum files uploaded during any one upload and the total uploads ever?
I may want to limit the total uploads into a given diretory, but I can do it from the PHP script.

Also, the field: uploadControl.ImageSize = 2000000; Does this limit the maximum file size?  It didn't seeem to work with an audio and a video file.  Is it in bytes?

Thanks
Tom
Dec 7, 2008 at 2:20 PM
Sorry... I forgot to mention that for DestinationDirectory, a relative path (from the PHP script directory) would be ideal, so for example you would say:

uploadControl.DestinationDirectory = "../data_files/";

Thanks
Tom
Dec 7, 2008 at 3:05 PM
Darick,

I was able to get the progress bar to work by setting the UploadChunkSize to a smaller number, it was set to 25000000 and I made it 40000.

I did notice a potential bug which is that when one of the files being sent up already exists, it prompts to upload, but if you say yes it doesn't upload any.
Another issue is that because of caching, if I remove the file from the server, the control still thinks that the file is there because the URL is the same.  One way to work around this is to make sure that the URL is unique.  You can add this code:

Random

 

random = new Random();
URL = URL +  "&Unused=" + random.Next().ToString();

So the only thing I need now is: uploadControl.DestinationDirectory = "../data_files/";

Thanks
Tom

 

Coordinator
Dec 7, 2008 at 6:54 PM
You can add this on the end of the UploadPage: upload.php?destinationDirectory=../data_files/
And then access the item from $_GET["destinationDirectory"] if using php.
Also, you can add the random value here as well.

Hope this helps.
Darick



From: notifications@codeplex.com
To: darick_c@hotmail.com
Date: Sun, 7 Dec 2008 08:05:34 -0800
Subject: Re: PHP backend version? [SilverlightFileUpld:41390]


.ExternalClass {font-family:Verdana;font-size:0.75em;} .ExternalClass #EC_ThreadNotificationFooter {border-top:1px solid #ccc;color:gray;} .ExternalClass #EC_ThreadNotificationPostBody {margin-bottom:2em;} .ExternalClass {font-family:Verdana;font-size:0.75em;} .ExternalClass #EC_ThreadNotificationFooter {color:gray;border-top:1px solid #ccc;} .ExternalClass #EC_ThreadNotificationPostBody {margin-bottom:2em;} From: tomgiam
Darick,

I was able to get the progress bar to work by setting the UploadChunkSize to a smaller number, it was set to 25000000 and I made it 40000.

I did notice a potential bug which is that when one of the files being sent up already exists, it prompts to upload, but if you say yes it doesn't upload any.
Another issue is that because of caching, if I remove the file from the server, the control still thinks that the file is there because the URL is the same. One way to work around this is to make sure that the URL is unique. You can add this code:

Random

random = new Random();
URL = URL + "&Unused=" + random.Next().ToString();

So the only thing I need now is: uploadControl.DestinationDirectory = "../data_files/";

Thanks
Tom



Read the full discussion online.
To add a post to this discussion, reply to this email (SilverlightFileUpld@discussions.codeplex.com)
To start a new discussion for this project, email SilverlightFileUpld@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


You live life online. So we put Windows on the web. Learn more about Windows Live
Dec 7, 2008 at 9:59 PM

Thanks,  that worked!!

I can now use it.

Is there any way to:

1. Limit the type of files uploaded (e.g only .jpg and .png or only .avi or only .mp3 etc...)

2. Limit the number of files uploaded to a directory ( I could create a separate php script that I can run to get the number of files in the directory before calling the control, but it would be better integrated in the control)

3. If I do my own PHP script in #2 can I then tell the control to only accept n number of files (i.e. maixum allowed - files already there)? 

4. Limit the size of files uploaded (does uploadControl.ImageSize = 2000000; work for all file types? it did not seem to work for video files).

Thanks
Tom

Coordinator
Dec 8, 2008 at 3:31 PM
1. Yes, add a filter to the upload control:
$Filter = "Images (*.jpg;*.png)|*.jpg;*.png";
2 & 3. I have added a parameter called MaxNumberToUpload. This will limit the amount of files they can upload. But you will have to use a php script to determine this amount. Especially since if it is hardcoded, all they would have to do is refresh the page and it would be reset. So in the php script, determine how many they can upload, then set the variable $MaxNumberToUpload to the amount (I've added this to the php example source code).
4. ImageSize if used when resizing images. Let's say you allow people to upload images, but don't want huge image files. Set $ResizeImage to true and $ImageSize to the max resolution size you want to allow. For example, setting $ImageSize to 1024 would resize all jpeg images to fit within 1024x1024 maintaining aspect ratio. $MaximumUpload is used to limit the size of the file to upload in bytes. While $MaximumTotalUpload limits the total size allowed to upload.

Hope this helps. Don't forget to update the xap file from the source.
Darick





From: notifications@codeplex.com
To: darick_c@hotmail.com
Date: Sun, 7 Dec 2008 14:59:24 -0800
Subject: Re: PHP backend version? [SilverlightFileUpld:41390]


.ExternalClass {font-family:Verdana;font-size:0.75em;} .ExternalClass #EC_ThreadNotificationFooter {border-top:1px solid #ccc;color:gray;} .ExternalClass #EC_ThreadNotificationPostBody {margin-bottom:2em;} .ExternalClass {font-family:Verdana;font-size:0.75em;} .ExternalClass #EC_ThreadNotificationFooter {color:gray;border-top:1px solid #ccc;} .ExternalClass #EC_ThreadNotificationPostBody {margin-bottom:2em;} From: tomgiam
Thanks, that worked!!

I can now use it.
Is there any way to:
1. Limit the type of files uploaded (e.g only .jpg and .png or only .avi or only .mp3 etc...)
2. Limit the number of files uploaded to a directory ( I could create a separate php script that I can run to get the number of files in the directory before calling the control, but it would be better integrated in the control)

3. If I do my own PHP script in #2 can I then tell the control to only accept n number of files (i.e. maixum allowed - files already there)?

4. Limit the size of files uploaded (does uploadControl.ImageSize = 2000000; work for all file types? it did not seem to work for video files).

Thanks
Tom

Read the full discussion online.
To add a post to this discussion, reply to this email (SilverlightFileUpld@discussions.codeplex.com)
To start a new discussion for this project, email SilverlightFileUpld@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Suspicious message? There’s an alert for that. Get your Hotmail® account now.
Dec 9, 2008 at 3:02 PM
Fantastic! Thanks for the quick responses.  I'll try those options soon.
I now feel obligated to donate some money for your great work.

BTW a couple of other options you may want to consider (I may need them in the future):

1. Programmaticaly provide the control a list of URLs (instead of filenames) to upload. 
    The control would then appear with the list of URLs ready to upload or the upload could be initiated programmatically as well.
    This is useful for moving files from one site to another (e.g. from Flickr)
2. Upload files to Flickr or other photo sharing sites.  This may be possible without any changes (just a different URL), but I haven't investigated it yet.

Thanks
Tom
Mar 11, 2009 at 1:15 PM
Hi

The "MaxNumberToUpload" parameter not works for me..
Can you check it?

Thanks!