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
In need of sum halps.
Re: In need of sum halps.
I don't know about viewing files already posted, but i use the following:
index.html
upload.php
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>
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.";
}
}
?>
Re: In need of sum halps.
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
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
Re: In need of sum halps.
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?
Re: In need of sum halps.
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.
Re: In need of sum halps.
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);
Re: In need of sum halps.
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.
Re: In need of sum halps.
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:
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 -->