Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
joanmjc  
#1 Posted : Monday, February 1, 2010 1:39:10 PM(UTC)
joanmjc

Rank: Member

Groups: Member
Joined: 11/26/2008(UTC)
Posts: 17

Hello I have almost none of PHP knowledge, can someone please give me the PHP code for this pseudocode so I can preserve folder structure on uploads

Quote:

iterate through each file (i)
{
//This value is taken from the FileName_i POST field
string fullPath

//This value is pre-defined
string galleryPath

//The 'split' function splits a string into an array of substrings using
//the specified delimiter ('\' in our case)
array folderStructure = split(fullPath, "\")

//The 'goToFolder' function changes the current working folder to the
//specified one
goToFolder(galleryPath)

iterate through each element of folderStructure (j)
{
//The 'exists' function checks if the specified folder exists under the
//current location
if not exists(folderStructure[j])
{
//The 'createFolder' function creates a subfolder
createFolder(folderStructure[j])
}
goToFolder(folderStructure[j])
}

//The 'save' function saves the current file in the current working folder
save(file[i])
}

Edited by user Tuesday, February 9, 2010 9:08:33 PM(UTC)  | Reason: Not specified

andreym  
#2 Posted : Wednesday, February 3, 2010 8:09:45 PM(UTC)
andreym

Rank: Advanced Member

Groups: Member
Joined: 6/16/2009(UTC)
Posts: 134

Was thanked: 8 time(s) in 8 post(s)
Hello! I've made small simple example of how to do this.
The upload.php file contains all code you need to save received files with preserving folder structure.
The index.php file contains the Image Uploader configuration settings to enable Upload Folder feature. The key options is AllowFolderUpload, IncludeSubfolders, ShowSubfolders.

You can find it in the attached archive.
File Attachment(s):
folder_structure.zip (2,101kb) downloaded 27 time(s).
joanmjc  
#3 Posted : Thursday, February 4, 2010 1:28:27 AM(UTC)
joanmjc

Rank: Member

Groups: Member
Joined: 11/26/2008(UTC)
Posts: 17

Almost done, only one little problem, the script is that is not creating folders properly yet, it does upload all files, but files inside a folder are created as "foldername\\filename1.jpg" "foldername\\filename2.jpg"

I mean the pictures inside a subfolder are renamed "foldername\\filename1.jpg"
joanmjc  
#4 Posted : Thursday, February 4, 2010 1:31:00 AM(UTC)
joanmjc

Rank: Member

Groups: Member
Joined: 11/26/2008(UTC)
Posts: 17

See image to better understanding..

UserPostedImage
andreym  
#5 Posted : Thursday, February 4, 2010 1:35:07 PM(UTC)
andreym

Rank: Advanced Member

Groups: Member
Joined: 6/16/2009(UTC)
Posts: 134

Was thanked: 8 time(s) in 8 post(s)
Oh, I think we should use DIRECTORY_SEPARATOR constant as path delimiter. I've made the necessary changes and attached updated sample to this post.
File Attachment(s):
folder_structure.zip (2,101kb) downloaded 31 time(s).
joanmjc  
#6 Posted : Thursday, February 4, 2010 8:12:18 PM(UTC)
joanmjc

Rank: Member

Groups: Member
Joined: 11/26/2008(UTC)
Posts: 17

Thanks! works like a charm now!!!
joanmjc  
#7 Posted : Thursday, February 4, 2010 9:03:58 PM(UTC)
joanmjc

Rank: Member

Groups: Member
Joined: 11/26/2008(UTC)
Posts: 17

Is there a way to specify that the created subfolders dont get owner permissions since its a mess to delete them I have to use this script:

<?php
$old = umask(0000);
chmod("foldername", 0777);
umask($old);
?>

editing the "foldername" each time i want to delete a folder uploaded, since every folder is under the 99 99 group, is there a way to change the group owner on the upload
Tamila  
#8 Posted : Monday, February 8, 2010 3:02:28 AM(UTC)
Tamila

Rank: Advanced Member

Groups: Member
Joined: 3/9/2008(UTC)
Posts: 554

Was thanked: 1 time(s) in 1 post(s)
Hi,

I hope the following code snippet helps you:
Code:
// Create directory if it not exists
if (!file_exists($absDirectoryName)) {
  $old = umask(0000);
  mkdir($absDirectoryName, 0777, TRUE); 
  umask($old);
}

Unfortunately we do not have appropriate soft ware to check it, so please let us know about your results.
Aurigma Support Team

UserPostedImage Follow Aurigma on Twitter!
joanmjc  
#9 Posted : Tuesday, February 9, 2010 7:20:01 PM(UTC)
joanmjc

Rank: Member

Groups: Member
Joined: 11/26/2008(UTC)
Posts: 17

Works excellent, now I can delete wichever folder or file any user upload without any problem, thanks
andreym  
#10 Posted : Wednesday, May 26, 2010 3:13:07 AM(UTC)
andreym

Rank: Advanced Member

Groups: Member
Joined: 6/16/2009(UTC)
Posts: 134

Was thanked: 8 time(s) in 8 post(s)
This is the same sample for ASP.NET on VB.NET.
File Attachment(s):
FolderUploadDemo_VB.zip (2,338kb) downloaded 43 time(s).
Users browsing this topic
Similar Topics
HOWTO: Preserve Folder Structure (Discussions – ActiveX/Java Uploader)
by joanmjc 2/1/2010 1:39:10 PM(UTC)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.