PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 2nd, 2012, 03:56 PM
vero vero is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Posts: 45 vero User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 h 14 m 36 sec
Reputation Power: 1
File Upload and Sessions

Hello,

I have a script that uploads a zipped folder and extracts folder to a directory. I have code that loops through the uploaded folder and run some other code. How would I prevent the uploaded folder from:

1. Being overridden by simultaneous uploads
2. Only loop through the folder that the user just uploaded not all the folders that are currently inside the directory

I'm not experienced with Sessions and not sure if this is the route to go. Any help is appreciated. Thank you!

Reply With Quote
  #2  
Old October 4th, 2012, 09:16 PM
E-Oreo's Avatar
E-Oreo E-Oreo is offline
Lost in code
Click here for more information.
 
Join Date: Dec 2004
Posts: 7,947 E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)  Folding Points: 945 Folding Title: Novice Folder
Time spent in forums: 2 Months 10 h 37 m 24 sec
Reputation Power: 7053
If the code is on separate pages you might use sessions, but that's not really clear from your description.

To prevent the files from being overridden, you would use a unique file name for it.
__________________
PHP FAQ
How to program a basic, secure login system using PHP
Connect with me on LinkedIn


Quote:
Originally Posted by Spad
Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

Reply With Quote
  #3  
Old October 5th, 2012, 02:14 AM
ksushil970 ksushil970 is offline
Permanently Banned
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Posts: 4 ksushil970 User rank is Second Lieutenant (5000 - 10000 Reputation Level)ksushil970 User rank is Second Lieutenant (5000 - 10000 Reputation Level)ksushil970 User rank is Second Lieutenant (5000 - 10000 Reputation Level)ksushil970 User rank is Second Lieutenant (5000 - 10000 Reputation Level)ksushil970 User rank is Second Lieutenant (5000 - 10000 Reputation Level)ksushil970 User rank is Second Lieutenant (5000 - 10000 Reputation Level)ksushil970 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 h 35 m 3 sec
Warnings Level: 10
Number of bans: 1
Reputation Power: 0
Quote:
Originally Posted by vero
Hello,

I have a script that uploads a zipped folder and extracts folder to a directory. I have code that loops through the uploaded folder and run some other code. How would I prevent the uploaded folder from:

1. Being overridden by simultaneous uploads
2. Only loop through the folder that the user just uploaded not all the folders that are currently inside the directory

I'm not experienced with Sessions and not sure if this is the route to go. Any help is appreciated. Thank you!



Use the unique id function or rand function, that will increase a table column, But you get the desired result you require.
\

Last edited by ManiacDan : October 5th, 2012 at 08:16 AM.

Reply With Quote
  #4  
Old October 8th, 2012, 09:56 PM
vero vero is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Posts: 45 vero User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 h 14 m 36 sec
Reputation Power: 1
Quote:
Originally Posted by E-Oreo
If the code is on separate pages you might use sessions, but that's not really clear from your description.

To prevent the files from being overridden, you would use a unique file name for it.


Sorry, I should've been more detailed. What I want to achieve is allow users to upload zipped folders to a directory/folder generated by PHP session. So, a new directory/folder, incremented by 1, is created everytime a user uploads a zipped folder. For example, upload001, upload002, etc.. I then want to create a cron job to delete the generated folder as well as the uploaded folder inside of it once a user downloads their files. Is this even possible?

Reply With Quote
  #5  
Old October 9th, 2012, 03:15 AM
badger_fruit's Avatar
badger_fruit badger_fruit is offline
Confused badger
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2009
Location: West Yorkshire
Posts: 760 badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 5 h 15 m 18 sec
Reputation Power: 339
Quote:
Originally Posted by vero
Sorry, I should've been more detailed. What I want to achieve is allow users to upload zipped folders to a directory/folder generated by PHP session. So, a new directory/folder, incremented by 1, is created everytime a user uploads a zipped folder. For example, upload001, upload002, etc.. I then want to create a cron job to delete the generated folder as well as the uploaded folder inside of it once a user downloads their files. Is this even possible?


Vero

A $_SESSION is a variable which remains in memory until it's unset (either by the browser closing or your script unsetting it). It's very handy to use it to pass certain variables from one page to another, say for example if your site requires a login, then you can store the user level or ID in the $_SESSION variable and reference that before delivering page content to the browser (as opposed to looking up information from a database each time the page is changed to see if the currently logged in user is allowed to view the content or not).

It does NOT however, allow multiple site visitors to share the values in there.

For example, if I had this script:-

PHP Code:
 session_start();
echo 
$_SESSION['myvalue']++; 


.. and browsed it in my web-browser, initially I would see nothing but then every refresh, I'd see a number 1 and then each subsequent refresh it would increment by 1 each time. If another visitor went to that web-page, they would see exactly the same, nothing then an incrementing counter starting at 1.

What you'd need to do is store the "current folder number" into a database (or text file or whatever) and then each time someone submits files, this would be incremented.

As for the CRON job, well, that's perfectly possible, just call the command-line PHP application. eg: "php /path/to/file.php".
__________________
The number for UK Emergencies is changing, the new number is 0118 999 881 999 119 7253

"For if leisure and security were enjoyed by all alike, the great mass of human beings who are normally stupefied by poverty would become literate and would learn to think for themselves; and when once they had done this, they would sooner or later realise that the privileged minority had no function and they would sweep it away"
- George Orwell, 1984

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > File Upload and Sessions

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap