Click to See Complete Forum and Search --> : Can this be done
Hola hoop
09-07-2004, 11:03 AM
Hey all, question
I am setting up an ftp site with my home comp being used as server. It is for a small gaming group to be able to download maps and mods from my comp. i aslo want people to upload so..
my question is:
is there any way that sumone could upload, say a scrrenshot, to my ftp site and to have that photo shown on the site without intervention from myself, moving or pasting the pic sumwhere
Like......could i say, create a blank webpage with 10 empty boxes on it. Everytime sumone uploads a pic they can choose the box where to place it for display (no editing permissions, simply write to the site.)
The idea being i want people to upload stuff that appears on the FTP site (not the website), ie pics and mods without me having to do all the work to display them?
Can this be done and i hope i made it clear what i would like to do
:t
DocEvi1
09-07-2004, 12:07 PM
yep, I do it on my site to populate combo boxes when I'm uploading my page.
I use PHP and all it does is read the directory and return an array, from there I can do what the hell I like with it.
Only problem you may have is that PHP won't read remote servers (i.e. my server on www.stefancarlton.net can't read the contents of a folder on www.sysopt.com from what I saw).
Hola hoop
09-07-2004, 12:31 PM
ty for reply, do you have any links so i can read up on arrays and how it would be implemented.
I was sure somthing could be done. PHP u say, as in the full program or is there a mini php program you can use?
Excuse me but i know little of php or java applets as my site is run on a server that doesnt allow any scripting of anysort. Im assuming that as the ftp server content and server program is held on my own comp, these restrictions will no longer apply?
Any help towards this end would be great
again, just want sumone to be able to upload a pic and see it displayed on that page
:t
DocEvi1
09-07-2004, 02:26 PM
function getDirFiles($dirPath)
{
$opened = opendir($dirPath);
while ($readdir = @readdir($opened))
if ($readdir<>"." && $readdir<>".." && eregi("\.jpg$", $readdir))
$filearr[] = $readdir;
closedir();
return $filearr;
}
function getDir($dir)
{
$dirlist=array();
$dh=opendir($dir);
if ($dh)
{
while ($filename=readdir($dh))
if (!is_file($filename) and !is_dir($filename))
$dirlist[]=$filename;
closedir($dh);
}
else
return false;
ksort($dirlist);
return $dirlist;
}
These are two the two functions which when ran on a PHP server (I'm assuming it's called via a suitable script in the page.php file) and called from a browser will list all available files within that directory, for instance:
<td width="63%"><select size="1" name="folder">
<?PHP
if( isSet($_POST['type']) )
{
$f = getDir($root."/".$_POST['type']);
for($i=0; $i<sizeOf($f); $i++)
{
print("<option");
if( isset($_GET['stage']) && $_POST['type'] == $f[$i])
{
print(" selected");
}
print(">".$f[$i]."</option>\n");
}
}
?>
</select></td> populates a combo (drop down) box with all the contents of folder "$root/$type" (variables for dyanmic programing).
DocEvi1
09-07-2004, 02:27 PM
if you email me via www.stefancarlton.net and you have PHP, I'm sure I'll be able to sort you out :)
Hola hoop
09-08-2004, 11:46 AM
Thanks a lot for that info DocEvi1, i will work on the server this weekend, and once i sorted php i will let you know. Ty for the code dude :D
DocEvi1
09-08-2004, 03:47 PM
apart from the bottom one, they were available via www.php.net (in the comments), very handy site that!
ahurtt
09-09-2004, 06:01 PM
You said:
"Excuse me but i know little of php or java applets as my site is run on a server that doesnt allow any scripting of anysort. Im assuming that as the ftp server content and server program is held on my own comp, these restrictions will no longer apply?"
If your website is hosted on one server, and your ftp server is hosted on your own personal machine, then how do you get the ftp content from your own personal machine to show up on your website without uploading it there yourself? If the server that hosts your website does not allow server-side scripting of any sort, you are gonna be hard pressed to do what you want to do in this case. Sounds like to do what you want to do, you would need to set up some web server on your personal machine and just host the website from there. Then you could run PHP, JSP, perl / CGI . . .or whatever you wanted.
Hola hoop
09-10-2004, 10:54 AM
i thought of that. I have only 1 machine so running a webserver from it would mean leaving it on all the time and would just be impractical. The idea here is to have the FTP site up in the evenings (people would get to know this arrangement)
I would have a link on my site to the FTP site (which hopefiully will display the uploaded images aswell as giving the option to upload, but not edit)
If people upload to the FTP server at home, they (hopefuilly) will be able to view the images they just uploaded by directory.
I am happy to do this, but i dont want to have to start producing new webpages to show the pictures (i realise i would have to upload the new images and directory to the ISP server)
The images will be stored on the home comp and when its on and the FTP server up, people will link straight in via address or link via site.
:t
SysOpt.com
Copyright Internet.com Inc. All Rights Reserved.