tables(i think) and uploadin
Moderator: General Moderators
tables(i think) and uploadin
Hi every one, ok i was wondering:
Is there a way to upload a file to a diff host then on the host that the script is on? see i want users to be able to upload files on to there game servers, but for that to work, it'd have to upload to the web server, then the game server! (using ftp) is there any other way? (hope i explained good)
ok 2:
I've always wondered, how do you make a script show new tables? like for example, a forum, when you go into a catogory, php makes all the tables, how do you do that? i hope i explained good..thanks!
Is there a way to upload a file to a diff host then on the host that the script is on? see i want users to be able to upload files on to there game servers, but for that to work, it'd have to upload to the web server, then the game server! (using ftp) is there any other way? (hope i explained good)
ok 2:
I've always wondered, how do you make a script show new tables? like for example, a forum, when you go into a catogory, php makes all the tables, how do you do that? i hope i explained good..thanks!
1)
yes you can do with FTP, i have setup soemthing like this for a client, except i copy the file from the game server to website server, it is very easy to do:
take a look at [php_man]ftp[/php_man] functions, you will need ftp copy function.
this is what you need to do (IMO)
- allow user to upload the file to your website server
- copy the file with ftp function to game server.
- delete the file on website server to save space.
thats it...
2)
mysql doest have a function to tell you what table is new...there is a way though but its kinda hard to expline lol, i will post later when i can think of some words for it lol.
yes you can do with FTP, i have setup soemthing like this for a client, except i copy the file from the game server to website server, it is very easy to do:
take a look at [php_man]ftp[/php_man] functions, you will need ftp copy function.
this is what you need to do (IMO)
- allow user to upload the file to your website server
- copy the file with ftp function to game server.
- delete the file on website server to save space.
thats it...
2)
mysql doest have a function to tell you what table is new...there is a way though but its kinda hard to expline lol, i will post later when i can think of some words for it lol.
1) ok, i just thought there might be another way, seeing as that takes x2 longer, oh well
2) ok i think i got a better explaination:
Ok, im making this download script, i want it to display uploaded files on the index of the page, so i would have to use tables, correct? but i cant figure out how to set tables like that in php
thanks
2) ok i think i got a better explaination:
Ok, im making this download script, i want it to display uploaded files on the index of the page, so i would have to use tables, correct? but i cant figure out how to set tables like that in php
thanks
- andre_c
- Forum Contributor
- Posts: 412
- Joined: Sun Feb 29, 2004 6:49 pm
- Location: Salt Lake City, Utah
You can do something like this:
I hope that helps
Code: Select all
<table>
<php?
$dir = 'path/to/your/files/';
if (is_dir($dir)) { //if directory exists
if ($dh = opendir($dir)) { //save to handle
while (($file = readdir($dh)) !== false) { //read each file
// if file is not parent or current directory (unix) or Thumbs.db (Windows)
if ($file!="." && $file!=".." && $file!="Thumbs.db") {
echo "<tr>\n"; // start a table row
// make a table cell and link to the file
echo '<td><a href="' . $dir . $file . '">' .$file . '</a></td>';
echo "</tr>\n"; // end the table row
}
}
closedir($dh); // close the directory
}
}
?>
</table>Thats exactly what i wanted, thank you.andre_c wrote:You can do something like this:
I hope that helpsCode: Select all
<table> <php? $dir = 'path/to/your/files/'; if (is_dir($dir)) { //if directory exists if ($dh = opendir($dir)) { //save to handle while (($file = readdir($dh)) !== false) { //read each file // if file is not parent or current directory (unix) or Thumbs.db (Windows) if ($file!="." && $file!=".." && $file!="Thumbs.db") { echo "<tr>\n"; // start a table row // make a table cell and link to the file echo '<td><a href="' . $dir . $file . '">' .$file . '</a></td>'; echo "</tr>\n"; // end the table row } } closedir($dh); // close the directory } } ?> </table>
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
string concatenation.
Code: Select all
$str1 = "Hello ";
$str2 = "World";
$hello = $str1 . $str1;
echo $hello . "!"; //echos Hello World!ohh!!!! thank you ! thats great!qads wrote:@ in front of function means it wont print a error message if it cant do what it was asked to, very useful when you dont want to show where you were trying to copy a file etc, dont use it when you are working on the script. put it in when the script is working.