Results 1 to 40 of 40

Thread: Uploading MANY Pictures!

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312

    Uploading MANY Pictures!

    Im in the process of writing a script which will upload many files. So far i have created a bit that will give me how many forms i need to upload however many files i need, but it doesnt upload them, or move them to another directory...

    I have looked through the forums and all the upload thingds only relate to doing one file...

    here my scripty!

    PHP Code:
    if($page=="4") {
        ?>
        <html><head><title>New Picture Section - Part 2</title></head>
        <body bgcolor="#CCCCCC">
        <font face="verdana" size="5">Add new Pictures to <?=$secname?><font size="2"><BR><BR>Upload Pictures and Info. This page will problalbly take you a long time, so i would get something downloading while your not using the net (as such :D). There is no reset button on here because if you hit it accidentally, you would be totally devistated :D:D<BR><BR>

        <?PHP

        
    if (isset($_POST['submit'])) {

        while(
    $y>1) {

            print 
    "this code is running<BR>";

            
    $noofpic $number;
            
    $big "big";
            
    $small "small";

          
    $fileUploadCopy $_FILES['$y$small']['tmp_name'];
          
    $fileUpload $_FILES['$y$small']['name'];
          
    $fileUploadCopy2 $_FILES['$y$big']['tmp_name'];
          
    $fileUpload2 $_FILES['$y$big']['name'];

          
    $imageName $fileUpload;
          
    $imageName2 $fileUpload2;

            
    $y--;

          if (
    $fileUploadCopy != "none") {
            
    copy($fileUploadCopy,"uploads/$imageName");
        }
          if (
    $fileUploadCopy2 != "none") {
            
    copy($fileUploadCopy2,"uploads/$imageName");
        }
          }
          }

        if(!
    $thumbnails==NULL && !$textforeach==NULL) {

            
    $noofpic $number;
            
    $y 0;
            
    $big "big";
            
    $small "small";

            
    #print "<table>";
            
    print "<form method=\"post\" enctype=\"multipart/form-data\">";
            
    #print "<input type=\"hidden\" name=\"page\" value=\"5\">";

            
    while($y $noofpic) {
                
    $s $y 1;
                print 
    "<table><TR><TD>Picture no.</td><td>$s</td></tr><tr><td>Thumbnail</td><td><input type=\"file\" name=\"$y\"></td></tr><tr><td>Big Picture</td><td><input type=\"file\" name=\"$y$small\"></td></tr><tr><td>Text</td><td><input type=\"text\" name=\"$y$big\"></td></tr></table><BR>";
                
    $y++;
            }

            print 
    "<input type=\"submit\" name=\"submit\" value=\"Upload\">";
            print 
    "</form>";

        }

    else print 
    "There has been an error while executing this script. Please retry, or send an email to the <a href=\"mailto:$webmasteremail?subject=Error with picture page\">webmaster</a>";
    }
    ?>
    as you can see i have used while loops and stuff, and tryed to double the amount of stuff you can upload, any help is appreciated, thanks
    Power to 2000 Electronic Donkeys!
    www.edonkey2000.com
    I hate case sensitivity... all you get down the M1 is "are we there yet" and "ouch, watch the bumps".

  2. #2
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    Make sure the directory you are uploading to is chmoded to 777
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    this is my own server so i have full access to everyhting :/
    Power to 2000 Electronic Donkeys!
    www.edonkey2000.com
    I hate case sensitivity... all you get down the M1 is "are we there yet" and "ouch, watch the bumps".

  4. #4
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    Are you on a NT or Unix server?
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    NT, win2k, running Apache

    It does work because i tried a test someone else posted on the board (it was you)

    PHP Code:
    <?PHP

    if (isset($_POST['submit'])) {
      
    $fileUploadCopy $_FILES['filename']['tmp_name'];
      
    $fileUpload $_FILES['filename']['name'];
      
    $imageName $fileUpload;
      if (
    $fileUploadCopy != "none")
        
    copy($fileUploadCopy,"uploads/$imageName");
    } else {
      echo 
    "<form method=\"post\" action=\"?\" enctype=\"multipart/form-data\">" .
              
    "<input type=\"file\" name=\"filename\">" .
              
    "<input type=\"submit\" value=\"upload\" name=\"submit\">";
    }

    ?>
    That works and was the basis for my script
    Power to 2000 Electronic Donkeys!
    www.edonkey2000.com
    I hate case sensitivity... all you get down the M1 is "are we there yet" and "ouch, watch the bumps".

  6. #6
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    take off the quotes around the variables:
    PHP Code:
          $fileUploadCopy $_FILES['$y$small']['tmp_name'];
          
    $fileUpload $_FILES['$y$small']['name'];
          
    $fileUploadCopy2 $_FILES['$y$big']['tmp_name'];
          
    $fileUpload2 $_FILES['$y$big']['name']; 
    should be:

    PHP Code:
          $fileUploadCopy $_FILES[$y$small]['tmp_name'];
          
    $fileUpload $_FILES[$y$small]['name'];
          
    $fileUploadCopy2 $_FILES[$y$big]['tmp_name'];
          
    $fileUpload2 $_FILES[$y$big]['name']; 
    -Matt
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    hmmm, it doesnt like that atall

    Parse error: parse error, unexpected T_VARIABLE, expecting ']' in C:\Program Files\Apache Group\Apache2\htdocs\PHP\MySite\admin\admin.php on line 149

    when they were inside ' ' s it gives no error
    Power to 2000 Electronic Donkeys!
    www.edonkey2000.com
    I hate case sensitivity... all you get down the M1 is "are we there yet" and "ouch, watch the bumps".

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    is it important that the fileupload vvariable is called fileupload? i mean it can be called fileupload 2 cant it...

    i wonder why i cant take the $y$big out of the ''s.
    Power to 2000 Electronic Donkeys!
    www.edonkey2000.com
    I hate case sensitivity... all you get down the M1 is "are we there yet" and "ouch, watch the bumps".

  9. #9
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    I see your problem now. $y$big is not the name of your second file. Your two file names are $y and $y$small
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    ahhhhhh, its not only that

    while tryign to create another script of the same type i ran into the problem The problem is that i am trying to use variables cleverly, my new script...

    PHP Code:
    if($section=="0") {
            
    $y 0;
            
    $text "text";
            
    $target"target";

            print 
    "<form name=\"linkys\" action=\"admin.php\">";
            print 
    "<input type=\"hidden\" name=\"page\" value=\"7\">";
            print 
    "<input type=\"hidden\" name=\"section\" value=\"2\">";
            print 
    "<input type=\"hidden\" name=\"numberof\" value=\"$numberof\">";


            while(
    $y $numberof) {
                
    $s $y 1;
                print 
    "<table><TR><TD>Link no.</td><td>$s</td></tr><tr><td>URL</td><td><input type=\"text\" name=\"$y\"></td></tr><tr><td>URL Text</td><td><input type=\"text\" name=\"$y$text\"></td></tr><tr><td>New Window</td><td><input type=\"checkbox\" name=\"$y$target\"></td></tr></table><BR>";
                
    $y++;
            }

            print 
    "<input type=\"submit\" value=\"Change Links\">";
            print 
    "</form>";
        }

        if(
    $section=="2") {

            
    $y 0;
            
    $t $numberof;
            
    $target "target";
            
    $text "text";

            
    $filename "links.txt";
            
    $fp fopen($filename,'w');
            
    fwrite($fp,"");
            
    fclose($fp);

            while(
    $y $t) {

                
    $ytext $y.text;

                
    $filename "links.txt";
                
    $fp fopen($filename,'a');
                
    fwrite($fp,"<a href=\"$1\"");

                if (
    $y.$target != NULL) {
                    
    fwrite($fp," target=\"_NEW\">$$ytext</a>");
                }
                else {
                    
    fwrite($fp,">$y.$text</a>");
                }

                
    fclose($fp);

                
    $y++;

            }

        } 
    Trys to dynamically create variables too, but when it comes to writing to a file, all i get it...

    <a href="$1" target="_NEW">$0text</a><a href="$1" target="_NEW">$1text</a>

    so all i nee dnow is a way around this, so that synamically created variablesa will work when tryed to run under a new condition (it ihnk)
    Power to 2000 Electronic Donkeys!
    www.edonkey2000.com
    I hate case sensitivity... all you get down the M1 is "are we there yet" and "ouch, watch the bumps".

  11. #11
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    with something like:

    "<a href=\"$1\""

    try

    "<a href=\"" . $1 . "\""

    i think this is what u need

    PHP Code:
    $fp fopen($filename,'a');
                
    fwrite($fp,"<a href=\"" . $"\"");

                if (
    $y.$target != NULL) {
                    
    fwrite($fp," target=\"_NEW\">" $y $text "</a>");
                }
                else {
                    
    fwrite($fp,">" $y $text "</a>");
                } 
    Last edited by nabeels786; Jul 6th, 2002 at 02:20 PM.
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  12. #12
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    then its the values of the variables.

    you have

    try changing:
    $y++;

    to

    $y+=1;

    change

    if($section=="2") {

    to

    elseif($section=="2") {


    what is $ytext = $y.text; ?
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  13. #13
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    try this

    PHP Code:
    $y 0;
    $text "text";
    $target"target";
    $t $numberof;

    if(
    $section=="0") {
           print 
    "<form name=\"linkys\" action=\"admin.php\">";
        print 
    "<input type=\"hidden\" name=\"page\" value=\"7\">";
        print 
    "<input type=\"hidden\" name=\"section\" value=\"2\">";
        print 
    "<input type=\"hidden\" name=\"numberof\" value=\"$numberof\">";


        while(
    $y $numberof) {
            
    $s $y 1;
            print 
    "<table><TR><TD>Link no.</td><td>" $s "</td></tr><tr><td>URL</td><td><input type=\"text\" name=\"" $y "\"></td></tr><tr><td>URL Text</td><td><input type=\"text\" name=\"" $y $text "\"></td></tr><tr><td>New Window</td><td><input type=\"checkbox\" name=\"" $y $target "\"></td></tr></table><BR>";
            
    $y+=1;
        }

        print 
    "<input type=\"submit\" value=\"Change Links\">";
        print 
    "</form>";
    } elseif(
    $section=="2") {
        
    $filename "links.txt";
        
    $fp fopen($filename,'w');
        
    fwrite($fp,"");
        
    fclose($fp);

        while(
    $y $t) {

            
    $ytext $text;

            
    $filename "links.txt";
            
    $fp fopen($filename,'a');

            if (
    $y.$target != NULL) {
                
    fwrite($fp,"<a href=\"" . $"\"  target=\"_NEW\">" $y $text "</a>");
            }  else {
                
    fwrite($fp,"<a href=\"" . $"\">" $y $text "</a>");
            }

            
    fclose($fp);

            
    $y+=1;

        }


    is the form on top submitting to itself?
    because the $text var is the same as the name of one of the form fields.
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  14. #14
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    This is just my opinion but if I were writing this I would make the form so it used an array and not just adding a 0text to the name.

    Something like this:
    PHP Code:
    print "<table><tr><td>Link no.</td><td>" $s "</td></tr>" .
           
    "<tr><td>URL</td><td><input type=\"text\" name=\"url[]\"></td></tr>" .
           
    "<tr><td>URL Text</td><td><input type=\"text\" name=\"urlText[]\"></td></tr>" .
           
    "<tr><td>New Window</td><td><input type=\"checkbox\" name=\"window[]\"></td></tr></table><BR>"
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  15. #15

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    AN ARRAY, YOUR A GENIOUS!!!!!!

    /me kissed cpradio

    Power to 2000 Electronic Donkeys!
    www.edonkey2000.com
    I hate case sensitivity... all you get down the M1 is "are we there yet" and "ouch, watch the bumps".

  16. #16

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    ok, i got this...

    PHP Code:
    if($page=="4") {
        ?>
        <html><head><title>New Picture Section - Part 2</title></head>
        <body bgcolor="#CCCCCC">
        <font face="verdana" size="5">Add new Pictures to <?=$secname?><font size="2"><BR><BR>Upload Pictures and Info. This page will problalbly take you a long time, so i would get something downloading while your not using the net (as such :D). There is no reset button on here because if you hit it accidentally, you would be totally devistated :D:D<BR><BR>

        <?PHP

        
    if (isset($_POST['submit'])) {

        while(
    $y>1) {

            print 
    "this code is running<BR>";

            
    $noofpic $number;

            
    $fileUploadCopy $_FILES['thumbnail[$y]']['tmp_name'];
              
    $fileUpload $_FILES['thumbnail[$y]']['name'];
              
    $fileUploadCopy2 $_FILES['bigpics[$y]']['tmp_name'];
              
    $fileUpload2 $_FILES['bigpics[$y]']['name'];

          
    $imageName $fileUpload;
          
    $imageName2 $fileUpload2;

            
    $y--;

          if (
    $fileUploadCopy != "none") {
            
    copy($fileUploadCopy,"uploads/$imageName");
        }
          if (
    $fileUploadCopy2 != "none") {
            
    copy($fileUploadCopy2,"uploads/$imageName");
        }
          }
    }

        if(!
    $thumbnails==NULL && !$textforeach==NULL) {

            
    $noofpic $number;
            
    $y 0;
            
    #$thumbnails[];
            #$smallpics[];
            #$text[];

            
    print "<form method=\"post\" enctype=\"multipart/form-data\">";

            while(
    $y $noofpic) {
                
    $s $y 1;
                print 
    "<table>
                <TR><TD>Picture no.</td><td>
    $s</td></tr>
                <tr><td>Thumbnail</td><td><input type=\"file\" name=\"thumbnail[
    $y]\"></td></tr>
                <tr><td>Big Picture</td><td><input type=\"file\" name=\"bigpics[
    $y]\"></td></tr>
                <tr><td>Text</td><td><input type=\"text\" name=\"text[
    $y]\"></td></tr></table><BR>";
                
    $y++;
            }

            print 
    "<input type=\"submit\" name=\"submit\" value=\"Upload\">";
            print 
    "</form>";

        }

    else print 
    "There has been an error while executing this script. Please retry, or send an email to the <a href=\"mailto:$webmasteremail?subject=Error with picture page\">webmaster</a>";
    }
    I tihnk i can problalbly work it out from here, as long as the variables work, which si the only thing im having trouble working out if they actually are doing :-/
    Power to 2000 Electronic Donkeys!
    www.edonkey2000.com
    I hate case sensitivity... all you get down the M1 is "are we there yet" and "ouch, watch the bumps".

  17. #17

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    you know what, ive completele lost what the hell im talking about :/

    this is the prblem with PHP, once you get some variable sinto play, a few loops and a big script, WHERE THE HELL IS WHAT YOUR LOOKING FOR
    Power to 2000 Electronic Donkeys!
    www.edonkey2000.com
    I hate case sensitivity... all you get down the M1 is "are we there yet" and "ouch, watch the bumps".

  18. #18
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by nabeels786
    with something like:

    "<a href=\"$1\""

    try

    "<a href=\"" . $1 . "\""

    i think this is what u need
    They are the same thing.

    Originally posted by nabeels786

    $y++;

    to

    $y+=1;
    And so are they. The way he is doing it is the more efficeint (correct) way of doing it. You're telling him to go from good programming to elementary.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  19. #19

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    yeah. And all im really trying to do first is get it working but as i say, all the script is confusing me now, i outta isolate it really and think about ti a bit
    Power to 2000 Electronic Donkeys!
    www.edonkey2000.com
    I hate case sensitivity... all you get down the M1 is "are we there yet" and "ouch, watch the bumps".

  20. #20

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    HAHA, IM A GENIOUS (allthough technically the idea was cpraio's )

    PHP Code:
    if($section=="0") {

            
    $y 0;

            print 
    "<form name=\"linkys\" action=\"admin.php\">";
            print 
    "<input type=\"hidden\" name=\"page\" value=\"7\">";
            print 
    "<input type=\"hidden\" name=\"section\" value=\"2\">";
            print 
    "<input type=\"hidden\" name=\"numberof\" value=\"$numberof\">";


            while(
    $y $numberof) {

                
    $s $y 1;

                print 
    "<table><TR><TD>Link no\.</td><td>$s</td></tr>";
                print 
    "<tr><td>URL</td><td><input type=\"text\" name=\"url[$y]\"></td></tr>";
                print 
    "<tr><td>URL Text</td><td><input type=\"text\" name=\"urltext[$y]\"></td></tr>";
                print 
    "<tr><td>New Window</td><td><input type=\"checkbox\" name=\"newwindow[$y]\"></td></tr>";
                print 
    "</table><BR>";

                
    $y++;

            }

            print 
    "<input type=\"submit\" value=\"Change Links\">";
            print 
    "</form>";
        }

        if(
    $section=="2") {

            
    $y 0;
            
    $t $numberof;

            
    $filename "../texts/links.txt";
            
    $fp fopen($filename,'w');
            
    fwrite($fp,"");
            
    fclose($fp);

                while(
    $y $t) {

                    
    $filename "../texts/links.txt";
                    
    $fp fopen($filename,'a');
                            
    fwrite($fp,"<a href=\"".$url[$y]."\"");

                            if (
    $newwindow[$y] != NULL) {
                                
    fwrite($fp," target=\"_NEW\">".$urltext[$y]."</a>");
                                }
                            else {
                                
    fwrite($fp,">".$urltext[$y]."</a>");
                            }

                    
    fclose($fp);

                    
    $y++;

                } 
    righty ho, my links creator now WORKS WITH dynamic link adding abilities

    time to do the same for the file upload script
    Power to 2000 Electronic Donkeys!
    www.edonkey2000.com
    I hate case sensitivity... all you get down the M1 is "are we there yet" and "ouch, watch the bumps".

  21. #21

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    im OH SO CLOSE to the pictures script running, just one thing i havent ocme accross, and neither has me book

    PHP Code:
    if ($page=="5") {

        if (isset(
    $_POST['submit'])) {

        
    $y 0;
        
    $s = (count($thumbnail)-1);

            while(
    $s>$y) {

                print 
    "this code is running<BR>";
                
    $noofpic $number;

                
    $fileUploadCopy $_FILES['thumbnail[$y]']['tmp_name'];
                 
    $fileUpload $_FILES['thumbnail[$y]']['name'];
                 
    $fileUploadCopy2 $_FILES['bigpics[$y]']['tmp_name'];
                  
    $fileUpload2 $_FILES['bigpics[$y]']['name'];

                
    $imageName $fileUpload;
                
    $imageName2 $fileUpload2;

                
    $y++;

                if (
    $fileUploadCopy != "none") {
                  
    copy($fileUploadCopy,"uploads/$imageName");
                }
                  if (
    $fileUploadCopy2 != "none") {
                     
    copy($fileUploadCopy2,"uploads/$imageName");
                }
            }
            print 
    "woo";
        }

    creates this error....

    Warning: Unable to open '' for reading: Permission denied in C:\Program Files\Apache Group\Apache2\htdocs\PHP\MySite\admin\admin.php on line 203

    Warning: Unable to open '' for reading: Permission denied in C:\Program Files\Apache Group\Apache2\htdocs\PHP\MySite\admin\admin.php on line 206

    i know it means it has no permission to open and upload the file, or copy it or whatever, but does anyone know how to get permission?

    Thanks you
    Power to 2000 Electronic Donkeys!
    www.edonkey2000.com
    I hate case sensitivity... all you get down the M1 is "are we there yet" and "ouch, watch the bumps".

  22. #22
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    Originally posted by The Hobo


    They are the same thing.



    And so are they. The way he is doing it is the more efficeint (correct) way of doing it. You're telling him to go from good programming to elementary.
    i know its the same, i was thinking maybe it was screwing up on that.
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  23. #23
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    chmod on the folders/
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  24. #24

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    well, i dont think CHMODing will help, its my server and my files, and besides i ddidnt think you needed to CHMOD to read anyway, it shouldnt be that, but i will try anyway..

    Another thing is i have a problem, my monitor set on fire today so im using my TV whihc as some of you may know is extremele low quality for text i can watch some nice films hopwever, anyway i might have to stop work on this, ill keep plugging till the pic script is done though
    Power to 2000 Electronic Donkeys!
    www.edonkey2000.com
    I hate case sensitivity... all you get down the M1 is "are we there yet" and "ouch, watch the bumps".

  25. #25
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by nabeels786
    chmod on the folders/
    You can't chmod on NT servers. Only on UNIX.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  26. #26

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    indeed
    Power to 2000 Electronic Donkeys!
    www.edonkey2000.com
    I hate case sensitivity... all you get down the M1 is "are we there yet" and "ouch, watch the bumps".

  27. #27
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    you need to set the folder permissions. So it can read, execute, and write.
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  28. #28
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by cpradio
    you need to set the folder permissions. So it can read, execute, and write.
    Maybe I'm confused, but didn't he already say that he did?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  29. #29
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    oops sorry, I really did not read too much of this thread recently, the problem is either you have mispelled a variable name or the form is not sending the information correctly because your copy() functions think the file you are trying to upload is '' (blank)
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  30. #30

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    cool, well at least this means im nearly there no doubt i will finish it tommorrow

    i tihnk then, that what your saying is all i have to do is get the program to read the variable correctly ? that shouldnt be too hard now im using arrays, i tryed using them on the links making page and it worked a treat

    thanks fro all j00 help
    Power to 2000 Electronic Donkeys!
    www.edonkey2000.com
    I hate case sensitivity... all you get down the M1 is "are we there yet" and "ouch, watch the bumps".

  31. #31
    Hyperactive Member Kagey's Avatar
    Join Date
    Sep 2000
    Location
    The Wilderness of New Brunswick
    Posts
    294
    try changing this:
    PHP Code:
    $fileUploadCopy $_FILES['thumbnail[$y]']['tmp_name'];
                 
    $fileUpload $_FILES['thumbnail[$y]']['name'];
                 
    $fileUploadCopy2 $_FILES['bigpics[$y]']['tmp_name'];
                  
    $fileUpload2 $_FILES['bigpics[$y]']['name']; 
    to this (double quoted)
    PHP Code:
    $fileUploadCopy $_FILES["thumbnail[$y]"]['tmp_name'];
                 
    $fileUpload $_FILES["thumbnail[$y]"]['name'];
                 
    $fileUploadCopy2 $_FILES["bigpics[$y]"]['tmp_name'];
                  
    $fileUpload2 $_FILES["bigpics[$y]"]['name']; 

  32. #32
    scoutt
    Guest
    kagey that will error out. you can't use " in the globals.

    Jaffer you are making thi shard on yourself. for one you can't use numbers as variables. $1 does not work.

    also if I'm not mistaken the $_FILES array looks like this

    $_FILES['thumbnail']['tmp_name'][$y];

    let me check and also see if I can come up with some thing better.

    also you migth want to try to add the whole path

    /path/to/uploads/$imageName

  33. #33
    Hyperactive Member Kagey's Avatar
    Join Date
    Sep 2000
    Location
    The Wilderness of New Brunswick
    Posts
    294
    scoutt's way of referencing the uploaded file array works. i am trying to do the same thing, and i just found an example in the manual.

    here is a php bit that will work. assuming that the picture upload fields were called pictures[]:
    PHP Code:
    $nPics = (count($pictures));

    for(
    $i 0$i $nPics$i++) {

        if(
    stristr($HTTP_POST_FILES['pictures']['type'][$i], 'image')){ // only accept picture files
        
            
    if (is_uploaded_file($HTTP_POST_FILES['pictures']['tmp_name'][$i]))
                
    copy($HTTP_POST_FILES['pictures']['tmp_name'][$i], 
                
    "somepath/" basename($HTTP_POST_FILES['pictures']['name'][$i]));
        }

    Last edited by Kagey; Jul 10th, 2002 at 05:57 PM.

  34. #34
    scoutt
    Guest
    if you set up the inputs in array like so

    <input type="file" name="uploadedfile[]">
    <input type="file" name="uploadedfile[]">
    <input type="file" name="uploadedfile[]">

    you could do something like so
    PHP Code:
    <?php
    if (isSet($_REQUEST['submit']))
    {
    $file_counter 0;
    $i 0;
    while (list (
    $key$file) = each ($_FILES))
    {
    if (
    $file['tmp_name'] != "none")
    {
    $uploaded_tmp_name $file['tmp_name'];
    $uploaded_name $file['name'];

    if (!
    copy($uploaded_tmp_name$upload_dir.$uploaded_name))
    {
    echo 
    " There was an ERROR when moving the file <b>\"$uploaded_name\"</b> to <b>\"$upload_dir\"!</b><br>";
    }
    else
    {
    echo 
    " A file <b>\"$uploaded_name\"</b> was moved to <b>\"$upload_dir\"</b> !<br>";
    }
    ?>
    you also have to remember what version of php you are trying to work woth as if it is 4.1 or 4.2 I don't think is_uploaded_file() works anymore.

  35. #35

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    IT WORKS

    HALE, THE CONQUERING HERO!!!

    DA DA DADADADA, DA DAAAAAAAAAAAAAAAAAAAAAAAAAA

    i am the mata when seeing your posts i thought that my code had to be right, i rewrote it loadas and loads! and then, THEM I REALISED, it wasnt passing $number because i kept refreshing, $number was potentially lost in the second stage, SO, i went back and put in hidden input field in the second stage, this notched it up and let the loop run,t hus uploading some files

    HARDCORE

    Thnak you all so much for helping me, i would have given up if people hadnt of kept tryign to give me new thinga to do
    Power to 2000 Electronic Donkeys!
    www.edonkey2000.com
    I hate case sensitivity... all you get down the M1 is "are we there yet" and "ouch, watch the bumps".

  36. #36

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    oh, and if your pondering my script, its...

    PHP Code:
    if($page=="3") {
        ?>
        <html><head><title>New Picture Section - Part 1</title></head>
        <body bgcolor="#CCCCCC">
        <font face="verdana" size="5">Add new Pictures<font size="2"><BR><BR>Add new Section of Pictures<BR><BR>
        <?PHP

        
    if($section=="2") {
        
    ?>
        <form name="getinfo" action="admin.php">
        <input type="hidden" name="page" value="3">
        <input type="hidden" name="section" value="0">
        <TABLE>
        <TR><TD>Thumbnails</td><td><input type="checkbox" name="thumbnails" checked><font size="1">Please note that NOT using this will mean your BIG image will be compressed to a thumbnail size</TD></TR>
        <TR><TD>Text for each Pic</td><td><input type="checkbox" name="textforeach" checked></TD></TR>
        <tr><td>New Section Name</td><td><input type="text" name="secname"></td></tr>
        <tr><td>Section Welcome Text</td><td><textarea cols="40" rows="5" name="welcome text"></textarea></td></tr>
        <tr><td>Number of Pictures</td><td><input type="text" name="number"></td></tr>
        <tr><td>Background Color (Pic Page)</td><td><input type="text" name="piccolor" value="#"></td></tr>
        <tr><td></td><td><input type="submit" value="Next Section"></td></tr>
        </table></form>
        </body></html>

        <?PHP
        
    }
        if(
    $section == "0") {

            
    $y=0;

            print 
    "<form name=\"cool\" method=\"POST\" action=\"admin.php\" enctype=\"multipart/form-data\">";
            print 
    "<input type=\"hidden\" name=\"page\" value=\"3\">";
            print 
    "<input type=\"hidden\" name=\"section\" value=\"1\">";
            print 
    "<input type=\"hidden\" name=\"number2\" value=\"$number\">";
            print 
    "<table>";

            while (
    $y $number) {
                print 
    "<tr><td>Link No.</td><td>$y</td></tr>";
                print 
    "<tr><td>Thumnail Link</td><td><input type=\"file\" name=\"thumbnail[$y]\"></td></tr>";
                print 
    "<tr><td>BigPic Link</td><td><input type=\"file\" name=\"bigpic[$y]\"></td></tr>";
                print 
    "<tr><td>Text</td><td><input type=\"text\" name=\"text[$y]\"></td></tr>";
                
    $y++;
            }

            print 
    "<tr><td></td><td><input type=\"submit\" name=\"submit\" value=\"Upload!\">";
            print 
    "</table></form>";
            }
            }

        if(
    $section=="1") {
            if (isset(
    $_POST['submit'])) {

                
    $y=0;
                
    $number $number2;

                while (
    $y $number) {
                      
    $fileUploadCopy $_FILES['thumbnail']['tmp_name'][$y];
                      
    $fileUpload $_FILES['thumbnail']['name'][$y];

                      print 
    $fileupload;

                      
    $imageName $fileUpload;
                      if (
    $fileUploadCopy != "none") {
                        
    copy($fileUploadCopy,"../pictures/uploaded/$imageName");
                    }

                     
    $fileUploadCopy $_FILES['bigpic']['tmp_name'][$y];
                     
    $fileUpload $_FILES['bigpic']['name'][$y];

                     
    $imageName $fileUpload;
                     if (
    $fileUploadCopy != "none") {
                       
    copy($fileUploadCopy,"../pictures/uploaded/$imageName");
                    }

                    
    $y++;
                }
            }
    }
    Power to 2000 Electronic Donkeys!
    www.edonkey2000.com
    I hate case sensitivity... all you get down the M1 is "are we there yet" and "ouch, watch the bumps".

  37. #37
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    tsk, tsk, tsk. you broke most of the 4.2 standards
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  38. #38

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    bah!!! as long as it works im happy
    Power to 2000 Electronic Donkeys!
    www.edonkey2000.com
    I hate case sensitivity... all you get down the M1 is "are we there yet" and "ouch, watch the bumps".

  39. #39
    New Member
    Join Date
    Jan 2003
    Posts
    1
    ok, im a complete newbie with a little knowledge of php

    but i dont get how the last script posted is supposed to work
    how can you start with an if statement without the "<?" ?
    im not sure what to change to be able to upload to the server im working with

  40. #40
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    he just forgot it. he must have more code above that that has the open <?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width