Folder upload

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
user___
Forum Contributor
Posts: 297
Joined: Tue Dec 05, 2006 3:05 pm

Folder upload

Post by user___ »

Hi guys,
I have to create an uploader which is supposed to upload whole directories. Is there any way that to be done? I am thinking of using Php and Flash?

Thanks.
User avatar
webspider
Forum Commoner
Posts: 52
Joined: Sat Oct 27, 2007 3:29 am

Re: Folder upload

Post by webspider »

as far as I know whole directories cann't be uploaded once unless it is zipped.

Here is a code for file upload

Code: Select all

<form action="upload_file.php" method="post" enctype="multipart/form-data">
<!-- MAX_FILE_SIZE (measured in bytes)must precede the file input field -->
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<label for="file">Filename:</label>
<input type="file" name="file" id="file" /> 
<br />
<input type="submit" name="submit" value="Submit" />
</form>
and upload_file.php to process file uploading

Code: Select all

if ($_FILES["file"]["error"] > 0)
   {
      echo "Error: " . $_FILES["file"]["error"] . "<br />";
   }
   else
   {
      echo "Upload: " . $_FILES["file"]["name"] . "<br />";
      echo "Type: " . $_FILES["file"]["type"] . "<br />";
      echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
      echo "Stored in: " . $_FILES["file"]["tmp_name"];
      
	  if (file_exists("upload/" . $_FILES["file"]["name"]))
      {
	     echo $_FILES["file"]["name"] . " already exists. ";
	  }  
	  else
	  {
	     move_uploaded_file($_FILES["file"]["tmp_name"],"upload/" . $_FILES["file"]["name"]);
		 echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
	  } 
   }
user___
Forum Contributor
Posts: 297
Joined: Tue Dec 05, 2006 3:05 pm

Reply

Post by user___ »

Thanks for the reply but there are ways of uploading a directory but I am not aware of them(Though I used Java for a project like that) but now I need a Flash and Php application. Does anyone has an idea?

Thanks.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

PHP will accept multiple files at once so the only obstacle is providing a decent interface to the user. With pure HTML you can only provide a series of <input type="file"> fields. I think there are flash embeds that will do a better job failing that you should look to the domain of the "Java Applet". I've seen them used on Facebook photo uploading pages.
user___
Forum Contributor
Posts: 297
Joined: Tue Dec 05, 2006 3:05 pm

Reply

Post by user___ »

Thank you ole,
Do you have an idea for a site that I can browse to see how the User interface is made. I know that the only problem is the way I let user to choose folders.

Thanks.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

Flickr!
user___
Forum Contributor
Posts: 297
Joined: Tue Dec 05, 2006 3:05 pm

Reply

Post by user___ »

Thanks for the reply but ir seems that Flickr is a usual uploader and there is not a folder uploader. If I am wrong please correct me. Any other ideas?
Post Reply