In need of sum halps.

Technical Chatter here.
Post Reply
User avatar
Geo
Forum Manager




Illusionist Stylist Advisor Pi
Connoisseur Pyre Socialist Tsunami

Posts: 4404
Joined: Sun Jun 19, 2005 1:01 am
Location: United Kingdom
Contact:

In need of sum halps.

Post by Geo »

Hey Guys, It's that time again. I have a (probably) unsolvable question/request.

I'm in need of a script or something, to put onto a webpage, to allow users to upload files to some webspace (read: the root of the file they're using the upload script on). It needs to also be able to show the files already on the webspace. If it means clicking a browse button, that's fine. But drag and drop would be awesome.

The closest thing I've found is called Webdisk, but only works in cPanel. I cannot and don't have cPanel.

I was hoping Lej might be able to help, because he had that upload script on his FTP site thingy.

Please let me know if you know of any such scripts, or if you're able to code one for me. I would probably pay.

Thanks,

Geo
Image
For extremely cheap web hosting and domains, PM me. Includes excellent control panel software and instant activation!
User avatar
WaeV




Advisor

Posts: 1045
Joined: Tue Jun 01, 2004 10:45 am
Location: New England

Re: In need of sum halps.

Post by WaeV »

I don't know about viewing files already posted, but i use the following:

index.html

Code: Select all

<form enctype="multipart/form-data" action="upload.php" method="POST">
Please choose a file: <input name="uploaded" type="file" /><br />
<input type="submit" value="Upload" />
</form> 
upload.php

Code: Select all

<?php
$target = "...";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$type = $_FILES['uploaded']['type'];
$ok=1;

//This is our size condition
if ($uploaded_size > 350000)
{
echo "Your file is too large.<br>";
$ok=0;
}

//This is our limit file type condition
if ($type =="text/php")
{
echo "No PHP files<br>";
$ok=0;
} 

//Here we check that $ok was not set to 0 by an error
if ($ok==0)
{
Echo "Sorry your file was not uploaded";
}

//If everything is ok we try to upload it
else
{
echo $type;
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}
?>
Image
User avatar
ScottyGEE




Visioneer Vector Mad Hatter Artisan
Snitch! Enthraller Pi Critic
Sorceror Droplet Scorched Earth Socialist
Advisor Articulatist 500

Posts: 7352
Joined: Sun Aug 15, 2004 9:08 pm
Location: Down under
Contact:

Re: In need of sum halps.

Post by ScottyGEE »

You could always have a php script to display folder contents then use that upload script...

What it sounded like to me is that you want an FTP to be setup in browser for people to use. You can use a php ftp script. Like this (pretty much a tutorial though)

Or, use a Java FTP client on your site like this one I found . Create a user that has restricted access to the area you want (that root directory? The way you worded it confused me [the root of their file/the same directory as page they're on, what?]) and let people use that. Either change the FTP app to login with those credentials straight away or have them above the app in text so people know what to input.

Not sure if this is what you'd like though ;p
Image
This collaboration is not endorsed by Halomods
Technically its only me animating though ;)
User avatar
Geo
Forum Manager




Illusionist Stylist Advisor Pi
Connoisseur Pyre Socialist Tsunami

Posts: 4404
Joined: Sun Jun 19, 2005 1:01 am
Location: United Kingdom
Contact:

Re: In need of sum halps.

Post by Geo »

Thanks Scotty, but not really after FTP. I don't know PHP, but how hard would it be to get a script that shows the contents of a directory, and like allows you to download the files, even if via right-click?
Image
For extremely cheap web hosting and domains, PM me. Includes excellent control panel software and instant activation!
User avatar
WaeV




Advisor

Posts: 1045
Joined: Tue Jun 01, 2004 10:45 am
Location: New England

Re: In need of sum halps.

Post by WaeV »

For viewing the files and downloading, all you need is a storage directory with no index.html. What I do is put the above code at /upload and have all the files be stored at /files. That way the users can see what's there, download what's there, and add to what's there. It's not as slick as you probably want it, but it works.
Image
User avatar
Tural




Conceptionist Acolyte Bloodhound Recreator
Socialist Connoisseur Droplet Scorched Earth
Grunge

Posts: 15628
Joined: Thu Jun 16, 2005 3:44 pm
Location: Lincoln, NE
Contact:

Re: In need of sum halps.

Post by Tural »

Code: Select all

<?php
//index.php

$handle = opendir('.');

while ($file = readdir($handle)) {
if ($file != '..' && $file != '.' && $file != 'index.php') {
echo '<a href="'.$file.'">'.$file.'</a><br>';
}
}

closedir($handle);
I think that's all you'd need as far as a script to list the files in a directory.
User avatar
Geo
Forum Manager




Illusionist Stylist Advisor Pi
Connoisseur Pyre Socialist Tsunami

Posts: 4404
Joined: Sun Jun 19, 2005 1:01 am
Location: United Kingdom
Contact:

Re: In need of sum halps.

Post by Geo »

I know I'm really pushing my luck now, but I need it to look slick. I'm happy to theme it or whatever, but is there a way to have the files listed in an existing HTML page, one that I've designed? Thanks for everything so far guys, I'm quite impressed.
Image
For extremely cheap web hosting and domains, PM me. Includes excellent control panel software and instant activation!
User avatar
Tural




Conceptionist Acolyte Bloodhound Recreator
Socialist Connoisseur Droplet Scorched Earth
Grunge

Posts: 15628
Joined: Thu Jun 16, 2005 3:44 pm
Location: Lincoln, NE
Contact:

Re: In need of sum halps.

Post by Tural »

You can toss the code there into an page you'd like, and toss any table formatting into the loop to make them fit in the design.

For instance:

Code: Select all

<table cols="2" border="1"> <!-- The first portion of your layout formatting -->

<?php
$handle = opendir('.');

while ($file = readdir($handle)) {
if ($file != '..' && $file != '.' && $file != 'index.php') {
echo '<tr><td>$file</td><td><a href="'.$file.'">Download</a></td></tr>'; //Here is each row of your table. As it loops through the files, it adds them each as a row to the table.
}
}

closedir($handle);
?>

</table> <!-- The end of your formatting -->
Post Reply