SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2002
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Three coding questions - File upload, reading a dir and secure POSTing

    Hello, I was working on a project when I stumbled into a few road blocks. If anyone can help with any of these with code, helpful suggestions or even a link to a tutorial it would help immensely.

    1. Does anyone have any suggestions or code for how to handle file uploading through a website on a Mac? I've noticed that vBulletin's file upload feature just doesn't show up for Macs so I thought it would be the different filesystem causing the problem.

    2. How do I make php scan a directory for .gif or jpg (or any, or all) files and generate a list of their names? In the absence of a file upload scrips I want to at least make it easy to fill in the path to the image you're looking for.

    3. Can anyone give me information of making secure POST requests? The server supports openssl but I don't know how to code for it and their site was down the last time I checked it for info. Any other good sources? I'm on a hosted server so installing something like cURL is not an option.

  2. #2
    SitePoint Wizard Chris82's Avatar
    Join Date
    Mar 2002
    Location
    Osnabrück
    Posts
    1,003
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    2nd:

    PHP Code:
    <?php

    $dh 
    opendir('.'); // current dir

    echo '<pre>';
    while (
    $file readdir($dh)) {
       if (
    preg_match("/\\.(gif|jpg)$/"$file))
          echo 
    "$file\n";
    }
    echo 
    '</pre>';

    closedir($dh);
    ?>
    if you want to store the filenames in an array to do further stuff with them use:


    PHP Code:
    <?php

    $dh 
    opendir('.'); // current dir
    $files = array();

    while (
    $file readdir($dh)) {
       if (
    preg_match("/\\.(gif|jpg)$/"$file))
          
    $files[] = $file;
    }

    closedir($dh);

    // now you can sort the $files array
    ?>
    Last edited by Chris82; Jul 2, 2002 at 07:35.

  3. #3
    SitePoint Guru okrogius's Avatar
    Join Date
    Mar 2002
    Location
    US
    Posts
    622
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    3.) Just make sure the form which you are submititng is at https://www.yourwebsite.com/.../yourform.php

  4. #4
    SitePoint Guru okrogius's Avatar
    Join Date
    Mar 2002
    Location
    US
    Posts
    622
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1.) Don't see how a user platform woudl affect. <input type="file"> shoudl work everywhere.


Bookmarks

Posting Permissions

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