Jump to content

To upload multiple image files

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
Divya

Divya

    Learning Programmer

  • Members
  • PipPipPip
  • 33 posts
I want to upload 9 image files and if i click the submit button,all the images should be sent to a folder named "images" and the thumbnail images of those images should be created and sent to a folder named "thumbnails" inside "images" folder.Also,the image path should be sent to the database..Is it possible??if so,pls guide me..

#2
amrosama

amrosama

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 8,674 posts
sorry for that spam above,
ive wrote a tutorial about that heres the link
yo homie i heard you like one-line codes so i put a one line code that evals a decrypted one line code that prints "i love one line codes"
eval(base64_decode("cHJpbnQgJ2kgbG92ZSBvbmUtbGluZSBjb2Rlcyc7"));
www.amrosama.com | the unholy methods of javascript

#3
jatin

jatin

    Newbie

  • Members
  • Pip
  • 1 posts
hi divya...........
below is the code how to upload multiple image files ,this code is in asp.net but easily can be converted to php .i m posting this code only for clarifying the basic concept behind uploading photos.

protected void Button1_Click(object sender, EventArgs e)
    {

        //for File Uploading
     
//Here FileUpload is a asp.net control but u can use the html file upload //control 
       
//FileUpload1 is for uploading first file
        FileUpload fileuploader;
        Label labeler;
        fileuploader = FileUpload1;
        labeler = Label1;
        callme(fileuploader, labeler);

//FileUpload2 is for uploading second file
        fileuploader = FileUpload2;
        labeler = Label2;
        callme(fileuploader, labeler);

//FileUpload3 is for uploading third file
        fileuploader = FileUpload3;
        labeler = Label3;
        callme(fileuploader, labeler);

//FileUpload4 is for uploading fourth file

        fileuploader = FileUpload4;
        labeler = Label4;
        callme(fileuploader, labeler);

    }

//this function actually perform file uploading

    public void callme(FileUpload FileUploader, Label labler)
    {
        try
            {
                System.IO.FileInfo ff = new System.IO.FileInfo(FileUploader.FileName);
                String extension= ff.Extension;
                if ((extension == ".jpg") || (extension == ".gif") || (extension == ".png") || ((extension == ".bmp")))
                {
                    string filename = FileUploader.FileName;
                    String albumTitle = txtTitle.Text;
                    FileUploader.SaveAs(Server.MapPath("~/Album/") + filename);

                    bool status = SavetoDatabase(filename, albumTitle);//use this //function only if u want to save the picture info in database also
                    if (status)
                        labler.Text = "Upload status: File uploaded!";
                    else
                        labler.Text = "Upload status: File uploading Failed!";
                    
                }
                else
                {
                    labler.Text += "Upload status: Only jpg/gif/png/bmp formats are accepted!";
                }
            }
            catch (Exception ex)
            {
                labler.Text += "Upload status: The file could not be uploaded. The following error occurred: " + ex.Message;
            }
    }




    protected bool SavetoDatabase(String fileName, int albumID)
    {
    //add here logic to save the image information into database like its name 

    }

Edited by WingedPanther, 07 July 2009 - 05:42 AM.
add code tags (the # button)