/    Sign up×
Community /Pin to ProfileBookmark

Select a folder to work with

Hi there
I need a way for the user to be a able to specify a URL or else browse to the folder on a server where images are stored. Once the folder is selected, php will process the images and store the names and path in the database. So how can I allow selecting of a folder on a server as apposed to a single file.
Any help will be appreciated
Many thanks ?

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@devel95Jan 08.2010 — Here is something that is pretty basic I use to view and delete old sessions that hang around my server for a bit. If you're proficient with PHP, there is probably some code in here you can use to get closer to your objective.

*************PHP*************

<?php

/*
2009-12-05*/

error_reporting(E_ALL); // server configured at 6135, increasing to 6143

ini_set('display_errors', 'On');

if ($_SERVER['REMOTE_ADDR']=='123.456.789.012' || $_SERVER['REMOTE_ADDR']=='987.654.321.098') { // these are the only 2 IP's that can use this script

$directory = '/tmp/'; // define the director to use off the server root

$filePattern = 'sess_'; // define the file pattern for filtering (optional)

/*NOTHING NEEDS TWEAKED BELOW THIS LINE*/
// delete file
if (isset($_GET['del'])) {
unlink($directory.$filePattern.$_GET['del']);
header('Location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']);
exit;
} // end delete file

// show file
if (isset($_GET['show'])) {
echo '<pre>';
echo '<p>'.date("F d, Y a\t h:i:sa",filemtime($directory.$filePattern.$_GET['show'])).' <a href="?del='.$_GET['show'].'">delete</a> <a href="'.$_SERVER['PHP_SELF'].'">return</a></p>';
$fopen = fopen($directory.$filePattern.$_GET['show'],"r");
while (!feof($fopen)) {
$record = fgets($fopen);
$results = explode(';',$record);
print_r($results);
}
fclose($fopen);
echo '</pre>';
exit;
} // end show file

$results = array();
$handler = opendir($directory);
while ($file = readdir($handler)) { if (substr($file,0,5)==$filePattern) $results[] = filemtime($directory.$file).'|'.$file.'|'.filesize($directory.$file); }
closedir($handler);
sort($results);
echo '<pre>';
echo '<p>There '.((count($results)==1)?'is':'are').' '.count($results).' open session'.((count($results)==1)?'':'s').' at '.date("h:i:sa").' (<a href="'.$_SERVER['PHP_SELF'].'">refresh</a>)</p>';
foreach ($results as $value) {
list($datetime,$session,$filesize) = explode('|',$value);
echo date("F d, Y a\t h:i:sa",$datetime);
echo ' ('.sprintf("&#37;4s",$filesize).'k)';
echo ' <a href="?del='.str_replace($filePattern,'',$session).'">clear</a>';
echo ' <a href="?show='.str_replace($filePattern,'',$session).'">view</a>';
$fopen = fopen($directory.$session,"r");
$record = fgets($fopen);
$result = explode('|',$record);
fclose($fopen);
$thisDomain = substr($result[1],(strpos($result[1],'"')-strlen($result[1]))+1);
echo ' '.sprintf("%-30s",$thisDomain);
echo ' '.sprintf("%-15s",$result[2]);
echo ' '.$result[3];
echo '<br />';
}
echo '</pre>';

}

else {

header('Location: http://'.$_SERVER['HTTP_HOST']);

exit;

}

?>

*****************************
Copy linkTweet thisAlerts:
@SrWebDeveloperJan 08.2010 — Please next time consider using the PHP code tag which has colored syntax highlighting and makes pasted code easier to read on the forum. Thanks.
Copy linkTweet thisAlerts:
@devel95Jan 08.2010 — SrWebDeveloper -- if your post is targeted to me, I am not sure how to do that. I am a novice Webdeveloper.com post-er. Thanks for pointing me in the direction you are referring too.
Copy linkTweet thisAlerts:
@devel95Jan 08.2010 — Scratch my last post. I went in on a new post and I think I found the way to "tag" php code. Will use it next time. Thank for enlightening me on it.
Copy linkTweet thisAlerts:
@SrWebDeveloperJan 08.2010 — When posting here and while using the editor, click once on the small "php" icon at the top of the editor, then paste your code, then click once more on the icon. ?
Copy linkTweet thisAlerts:
@SrWebDeveloperJan 08.2010 — scratch my last post. I went in on a new post and i think i found the way to "tag" php code. Will use it next time. Thank for enlightening me on it.[/quote]

Nice!

-jim
×

Success!

Help @codeFunkd spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...