Jump to content

Dorky

Members
  • Posts

    287
  • Joined

  • Last visited

    Never

Posts posted by Dorky

  1. ok im down to this. it returns the altered array but i dont have a clue about how to get this back into a string with the top level array ending in /n and deviding the lower level array with ||

     

    $dumplink = $_GET['access'];
    $dumplinkinfo = file("$dumplink.html");
    foreach($dumplinkinfo as $dumplinkkey => $dumplinkval) 
    {
       $dumplinkdata[$dumplinkkey] = explode("||", $dumplinkval);
    }
    for($dumplinkk = 0; $dumplinkk < sizeof($dumplinkinfo); $dumplinkk++) 
    {
    unset($dumplinkdata[$dumplinkk][0]);
    unset($dumplinkdata[$dumplinkk][1]);
    unset($dumplinkdata[$dumplinkk]);
    print_r($dumplinkdata);
    }

     

    linkname || linkurl.com

    linkname || linkurl.com

    linkname || linkurl.com

    linkname || linkurl.com

     

    is the desired flat file format im trying to get the array down to.

  2. ok i got the name and url into a sortable format in the file and can pull it in the order i want it. any advice on how to remove 1 entry from an array so i can write all but the defined $var back to the file.

  3. sweet, i just realized to pull the same data so i can populate the delete list i need to create a 2x array for each entry. one $var for the name and one $var for the url so i can pull from the same file to populate the delete list and the visitor side. i will need to be able to pull by $var[] and not sure how yet im going to give a distinction to each array. an array of arrays?

     

    any advice on engineering this is very appreciated.

  4. got a file, lets call it file a. file a has links stored in it so they can be used by include to populate a links list managed by the site owner. i need to figure out how to make the entry go to the next line instead of inline every time it gets added to. and how to delete the line from the array i pull it into. i know how to pull each line into the array and how to write each link to it, just not real well at organizing it.

  5. you could just use a for loop. im assuming you want to do some image upload kind of thing

    for ($i = 0; $i < count($_POST['new_image']['name']); $i++){
    //access each individual element like so
    $name = $_POST['new_image']['name'][$i];
    $size = $_POST['new_image']['size'][$i];
    //do rest of stuff
    }
    

    DUDE YOU ARE  THE MAN!!!!!

     

    for ($i = 0; $i < count($_FILES['new_image']); $i++){
    $imagename = $_FILES['new_image']['name'][$i];
    $tmp_name = $_FILES['new_image']['tmp_name'][$i];

    how long did that take you. i missed an entire nights sleep for that.

  6. outside Array

    (

    [name] => Array ( [0] => d.png [1] => sky.jpg )

    [type] => Array ( [0] => image/png [1] => image/jpeg )

    [tmp_name] => Array ( [0] => /tmp/phpeKr1qV [1] => /tmp/phpiII3hp )

    [error] => Array ( [0] => 0 [1] => 0 )

    => Array ( [0] => 1028 [1] => 110116 )

    )

     

    inside Array ( [0] => d.png [1] => sky.jpg )

    inside Array ( [0] => image/png [1] => image/jpeg )

    inside Array ( [0] => /tmp/phpeKr1qV [1] => /tmp/phpiII3hp )

    inside Array ( [0] => 0 [1] => 0 )

    inside Array ( [0] => 1028 [1] => 110116 )

  7. yeah i figured that out but i have no idea how to get this into a workable array. it doesnt keep the right structure for some reason. this is the structure before and after the foreach loop indicated by "inside" and "outside"

     

    outside Array ( [name] => Array ( [0] => d.png [1] => sky.jpg ) [type] => Array ( [0] => image/png [1] => image/jpeg ) [tmp_name] => Array ( [0] => /tmp/phpX40sIK [1] => /tmp/php1TmAiS ) [error] => Array ( [0] => 0 [1] => 0 ) => Array ( [0] => 1028 [1] => 110116 ) )

    inside Array ( [name] => [type] => [tmp_name] => [error] => 4 => 0 ) inside Array ( [name] => Array ( [0] => d.png [1] => sky.jpg ) [type] => Array ( [0] => image/png [1] => image/jpeg ) [tmp_name] => Array ( [0] => /tmp/phpX40sIK [1] => /tmp/php1TmAiS ) [error] => Array ( [0] => 0 [1] => 0 ) => Array ( [0] => 1028 [1] => 110116 ) )

  8. i cannot find how to break down an array from multiple image post into a usable array to use in a foreach loop?

     

    results from a print_r of the $_POST['new_image']

     

    Array ( [name] => Array ( [0] => d.png [1] => sky.jpg ) [type] => Array ( [0] => image/png [1] => image/jpeg ) [tmp_name] => Array ( [0] => /tmp/php6WChM0 [1] => /tmp/phpU1UV9g ) [error] => Array ( [0] => 0 [1] => 0 ) => Array ( [0] => 1028 [1] => 110116 ) ) Array ( [0] => d.png [1] => sky.jpg ) Array ( [0] => image/png [1] => image/jpeg ) Array ( [0] => /tmp/php6WChM0 [1] => /tmp/phpU1UV9g ) Array ( [0] => 0 [1] => 0 ) Array ( [0] => 1028 [1] => 110116 )

  9. if (isset($_FILES['new_image']))
    {
    if (!empty($_POST['address']) && !empty($_POST['city']) && !empty($_POST['state']) )
    {
    //...
    $filepaths[] = $_FILES['new_image'];
    $listing = $_POST['address'];
    mkdir("/home/p14tnue3/public_html/howton/images/gallery/$listing" , 0755 );
    mkdir("/home/p14tnue3/public_html/howton/images/gallery/thumbs/$listing" , 0755 );
    foreach ($filepaths as $imgkey => $filepath)
    {
    $imagename = strtolower($filepath['name']);
    $charref = substr($imagename, 0, strrpos($imagename, '.')); 
    if(ctype_alnum($charref)) 
    {
    if (($pos = strrpos($imagename, ".")) === FALSE) { echo  "<p class=\"p7\">Fail</p><br />"; exit; }
    else {  $extension = substr($imagename, $pos + 1); $imagename = "$imgkey.$extension"; }
    if ( $extension == "jpg" || $extension == "gif" || $extension == "png"   ) 
    { 
    $source = $filepath['tmp_name'];
    $target = "images/gallery/$listing/$imagename";
    move_uploaded_file($source, $target);
    $file = "images/gallery/$listing/$imagename"; 
    $save = "images/gallery/$listing/$imagename";
    list($width, $height) = getimagesize($file) ; 
    if ($width > "500" )
    { 
    $modwidth = 500; 
    }
    else
    {
    $modwidth = $width ;
    } 
    $diff = $width / $modwidth;
    $modheight = $height / $diff; 
    $tn = imagecreatetruecolor($modwidth, $modheight) ; 
    if( $extension == "jpg" ) { $image = imagecreatefromjpeg ($file); }
    if( $extension == "gif" ) { $image = imagecreatefromgif ($file);  }
    if( $extension == "png" ) { $image = imagecreatefrompng ($file);  } 
    imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; 
    if( $extension == "jpg" ) { imagejpeg($tn, $save, 100) ;  }
    if( $extension == "gif" ) { imagegif($tn, $save, 100) ;  }
    if( $extension == "png" ) { imagepng($tn, $save, 9) ;  }
    $save = "images/gallery/thumbs/$listing/$imagename";
    list($width, $height) = getimagesize($file) ; 
    if ($width > "100" )
    { 
    $modwidth = 100; 
    }
    else
    {
    $modwidth = $width ;
    }  
    $diff = $width / $modwidth;
    $modheight = $height / $diff; 
    $tn = imagecreatetruecolor($modwidth, $modheight) ; 
    if( $extension == "jpg" ) { $image = imagecreatefromjpeg ($file); }
    if( $extension == "gif" ) { $image = imagecreatefromgif ($file);  }
    if( $extension == "png" ) { $image = imagecreatefrompng ($file);  } 
    imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; 
    if( $extension == "jpg" ) { imagejpeg($tn, $save, 100) ;  }
    if( $extension == "gif" ) { imagegif($tn, $save, 100) ;  }
    if( $extension == "png" ) { imagepng($tn, $save, 9) ;  }
    $imginfo = "Images Uploaded Successfully";
    $address = "";
    $city = "";
    $state = "";
    } 
    else 
    {
    $imginfo = "Invalid or empty File <br>Valid file types .jpg .gif .png";
    $address = $_POST['address'];
    $city = $_POST['city'];
    $state = $POST['state'];
    } 
    }
    else 
    { 
    $imginfo = "Image name may have alphanumeric characters only and no spaces $charref";
    $address = $_POST['address'];
    $city = $_POST['city'];
    $state = $POST['state'];
    }
    }
    //...
    }
    else
    {
    $imginfo = "Please complete all fields for listing";
    $address = $_POST['address'];
    $city = $_POST['city'];
    $state = $POST['state'];
    }
    }

  10. i added $imgkey => and use it to rename the file and whats happening is it writes the final image as 0 so its as if my foreach loop isnt advancing thrue the array but it is because it because its running the first image but then overwriting it with the name of the first.

  11. $filepaths[] = $_FILES['new_image'];
    foreach ($filepaths as $filepath)
    {
    $imagename = strtolower($filepath['name']);
    $charref = substr($imagename, 0, strrpos($imagename, '.')); 
    if(ctype_alnum($charref)) 
    {

    this is for a form with multiple image uploads that need to be resized. im trying to loop them thrue the resize script but it over writes as it goes untill the only img when its done is the final image field.

  12. I have a gallery to build and want to build a dynamic upload form to allow for $var number of fields but have a 30 sec execution limit on my host. im looking for advice on how to loop thrue up to 8 images but running each loop as a single execution so my script doesnt crash due to timeout.

    • use more space, im using to much space
    • its boring and plain, those things are pointless

    i dont see as much of a consensus as you all are eluding to. in fact your opinions all pull back and forth and other then the scaling issue are just opinions and not backed up with any facts or even links to any facts. i love that you all are helping but im done with this thread.

  13. <html>
    <head>
    <style>
    body {
    background-color: #000000;
    color: #ffffff;
    }
    #box {position: relative;  width: 750px;  height: 100%;  margin-left: auto; margin-right: auto; }
    #box h1 { color: #ff0000; text-align: center; }
    #box img { border: 0px; }
    #box .Banner {
    border-style: solid;
    border-width: 1px;
    border-color:red;
    width:750px;
    height:150px;
    float:left;
    }
    #box .leftmenu {
    background-color: #990000;
    border-style: solid;
    border-color: #990000;
    border-width: 1px;
    margin-right:5px;
    margin-bottom:100px;
    margin-top:5px;
    width:200px;
    height:100%;
    float:left;
    }
    #box .Content {
    width:500px;
    height:100%;
    text-align: center;
    float:left;
    }
    </style>
    </head>
    <body>
    <div id="box">
    <div class='banner'><h1>Banner Here<h1></div> <br />
    <div class='leftmenu'><a href='Signup.php'><img src='signup.png' /></a></div>
    <div class='Content'>....</div>
    </div>
    </body>
    </html>
    

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.