Activity Stream
48,167 MEMBERS
6941 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 4 of 4
  1.     
    #1
    Member
    Website's:
    Elite.SO Defendos.com Motionite.com

    Default [C#] File Upload + PHP - Discussion and Help

    Hello, I'm new to C# so I created this thread to get help regarding this tool I was playing with

    I don't need complete and working code posted here, I want help and code snippets.

    This is what I want:
    - File upload progress bar/dialog.
    - Random file name generation.
    - Dialog on upload finish, I couldn't get this working.

    I already got this...

    C# Code:
    PHP Code: 
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Net;

    namespace 
    WindowsFormsApplication6
    {
        public 
    partial class Form1 Form
        
    {
            public 
    Form1()
            {
                
    InitializeComponent();
            }

            private 
    void button1_Click(object senderEventArgs e)
            {
                
    //
                
    string a;
                
    textSource.Text;
                
    System.Net.WebClient Client = new System.Net.WebClient();

                
    Client.Headers.Add("Content-Type""binary/octet-stream");

                
    byte[] result Client.UploadFile("http://xcoderz.net/test/upload.php""POST", @a);

                
    string s System.Text.Encoding.UTF8.GetString(result0result.Length);
                
            }

            private 
    void button2_Click(object senderEventArgs e)
            {
                
    OpenFileDialog fdlg = new OpenFileDialog();
                
    fdlg.Title "Open file...";
                
    fdlg.InitialDirectory = @"c:\";
                fdlg.Filter = "
    All files (*.*)|*.*|All files (*.*)|*.*";
                fdlg.FilterIndex = 2;
                fdlg.RestoreDirectory = true;
                if (fdlg.ShowDialog() == DialogResult.OK)
                {
                    textSource.Text = fdlg.FileName;
                }
            }
        }

    PHP Uploaded file processor:
    PHP Code: 
    <?php

    $uploaddir 
    'upload/';

    if (
    is_uploaded_file($_FILES['file']['tmp_name'])) {

    $uploadfile $uploaddir basename($_FILES['file']['name']);

    echo 
    "File "$_FILES['file']['name'] ." uploaded successfully. ";

    if (
    move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {

    echo 
    "OKAY!";

    }

    else

    print_r($_FILES);

    }

    else {

    echo 
    "ERROR!";

    print_r($_FILES);

    }

    ?>
    l0calh0st Reviewed by l0calh0st on . [C#] File Upload + PHP - Discussion and Help Hello, I'm new to C# so I created this thread to get help regarding this tool I was playing with :P I don't need complete and working code posted here, I want help and code snippets. This is what I want: - File upload progress bar/dialog. - Random file name generation. - Dialog on upload finish, I couldn't get this working. I already got this... Rating: 5

    Defendos BETA3 Released! Thread - Official Website

  2.   Sponsored Links

  3.     
    #2
    Member
    You need to use an uploading method that supports uploading in chunks, that's where you will get the progress bar information from ((sent bytes * 100) / total bytes).

    This also includes Dialogue on Upload Finish - just make it show up when sent bytes >= total bytes.

    Random file name generation should be an easy task too or are you looking for something specific?
    The quick & dirty version would be creating a function that returns a string using the Random class.
    For strings you can take a look at this:
    Code: 
    http://www.c-sharpcorner.com/UploadFile/mahesh/RandomNumber11232005010428AM/RandomNumber.aspx
    Let's hear if you need code examples or if this already put you on the right track

  4.     
    #3
    Member
    Website's:
    Elite.SO Defendos.com Motionite.com
    I tried something from scratch but it's definatly wrong, so I tried again do you have a start for me?

    Defendos BETA3 Released! Thread - Official Website

  5.     
    #4
    Respected Developer
    For all the stuff you want there are plenty of articles on Google that can help you. Most can be done in multiple ways. As for the random names, trust me, you don't want random names because they can conflict. You want a unique name. And that doesn't have to be random. This is one way of doing it in C#:

    PHP Code: 
    string uniqueName String.Format("{0:x}.ext"DateTime.Now.Ticks); 

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Monster Upload Discussion - What do you want
    By monstersuppor in forum File Host Discussion
    Replies: 20
    Last Post: 14th Oct 2012, 06:09 PM
  2. Replies: 3
    Last Post: 10th Jun 2012, 12:08 PM
  3. Replies: 1
    Last Post: 20th Jul 2011, 04:31 PM
  4. Discussion: File hosts overflow
    By Chugi in forum File Host Discussion
    Replies: 11
    Last Post: 18th May 2011, 10:30 PM
  5. Replies: 3
    Last Post: 28th Apr 2011, 12:28 PM

Tags for this Thread

BE SOCIAL