0

Hello,
The following script writes to a file include.php

<?php

    $path = "./files/";
    $path2="http://".$_SERVER['SERVER_NAME'].dirname($_SERVER["PHP_SELF"])."/files/";
    //echo $path2;
    $folder = opendir($path);
    $start="";
    $Fnm = "./include.php";
    $inF = fopen($Fnm,"w");
    fwrite($inF,$start."\n");
    while( $file = readdir($folder) ) {

     if (($file != '.')&&($file != '..')&&($file != 'index.htm')) {
    $result="{\nlevels: [\n{ file: \"$path2$file\" }\n],\n\ntitle: \"$file\"\n},\n";

     fwrite($inF,$result);

     }
    }

    fwrite($inF,"");
    closedir($folder);
    fclose($inF);



    ?>

It searches the folder and look for any file and store it in $path2$file
so the result posted in include.php is (If the folder has one file)

{
levels: [
{ file: "path to/files/filename" }
],

title: "filename"
},

and if the folder has 2 files result is

{
    levels: [
    { file: "path to/files/filename1" }
    ],

    title: "filename2"
    },

{
    levels: [
    { file: "path to/files/filename2" }
    ],

    title: "filename2"
    },

and so on...

What I need is to search for another folder /images and write the same image file in include.php just below: { file: "path to/files/filename1" }

So the result will be

 {
        levels: [
        { file: "path to/files/filename1" }
        ],
  image: "path to/images/imagefilename1",    
        title: "filename2"
        },

and it will post the same image path for every image file in images folder

I have tried to incorporate the same code with slight variable changes but I am stuck at using while

Any help ?

Edited by ska_defender

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by Morta
0

hiiii, check that code:

<?php
$iname=$_FILES["pimg"]["name"];
if((@move_uploaded_file($_FILES["pimg"]["tmp_name"],"C:\images/pt/".$iname)))
     echo "<script>alert('!Data inserted successfully!!');</script>";
?>

in the form the method="POST" ,and enctype="multipart/form-data"
input name is "pimag" :

      <form enctype="multipart/form-data" action="" name="formp" method="POST" >
      <input type="file" name="pimg" id="pimg" >
      <input name="snd" type="password" value="Upload">
      </form>

** note** :the folder c:\images/pt must be exist.
%%^Murtada^%%

Edited by Morta

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.