pathans
Posts: 46
|
Posted: 10/09/2012, 10:20 PM |
|
I am uploading an image and upload is working fine.
but i want to upload the file with original name. i don't want system to auto increment anything.
I am using php and mysql.
I am sure you can tell i am a newbie...
|
|
|
bannedone
Posts: 273
|
Posted: 10/09/2012, 10:25 PM |
|
Hmmm..
Why do you need to do that??
By doing that could really cause you fits down the road.
BTW CCS does not auto increment the filename.. It actually adds a timestamp.
_________________
John Real
CodeCharge Studio Support, Training, Consulting, Development, Web based solutions
http://realsites.biz
http://ccselite.com
Other Banned IDs on this Forum. jjrjr1, jjrjr2 |
|
|
bannedone
Posts: 273
|
Posted: 10/10/2012, 7:11 AM |
|
Maybe this will answer all your questions
http://forums.yessoftware.com/posts.php?post_id=106430&s_keyword=upload
_________________
John Real
CodeCharge Studio Support, Training, Consulting, Development, Web based solutions
http://realsites.biz
http://ccselite.com
Other Banned IDs on this Forum. jjrjr1, jjrjr2 |
|
|
MichaelMcDonald
Posts: 640
|
Posted: 10/11/2012, 3:49 AM |
|
Have a look in classes.php
function Upload($RowNumber = "")
Keep in mind as bannedone points out that having every filename unique maintains referential integrity - this is like a golden rule of DB management. If you must rename a file try to put it in a table where there is another field which could be searched in conjunction with your filename so that the combination of the two fields make it a unique result, or create some unique concatenations and generate the name in a useable form.
Here is where I do something like this:
$fn1 = CCGetSession("UserID");
$fn2 = CCGetFromGet("siteid");
$fn3 = time();
$fn4 = substr(str_shuffle(str_repeat('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',5)),0,10);
$ActualFileName = "$fn4-$fn3-$fn2-$fn1.pdf";
_________________
Central Coast, NSW, Australia.
|
|
|
bannedone
Posts: 273
|
Posted: 10/11/2012, 6:45 AM |
|
Michael
That is not exactly what I was trying to point out.. LOL
However, I am curious what your issue/point is here.
Can you explain??
I can be dense at times..
Thanks
_________________
John Real
CodeCharge Studio Support, Training, Consulting, Development, Web based solutions
http://realsites.biz
http://ccselite.com
Other Banned IDs on this Forum. jjrjr1, jjrjr2 |
|
|
MichaelMcDonald
Posts: 640
|
Posted: 10/12/2012, 12:25 AM |
|
from this post discussing that CCS makes sure that no 2 filenames are the same, and also preventing a situation where both Mary and Lucy cannot have the same filename of their dads photo.....
http://forums.yessoftware.com/posts.php?post_id=106430&s_keyword=upload
Impresses the importance of unique filenames for uploads.
_________________
Central Coast, NSW, Australia.
|
|
|
pathans
Posts: 46
|
Posted: 10/12/2012, 11:54 AM |
|
I think i understand this now and ok with leaving file name intact after upload.
thanks guys....
|
|
|
aewhite901
Posts: 36
|
Posted: 10/16/2012, 5:18 PM |
|
Classes.php has a single line I think it is 1829 or around there
look for this...
while($file_exists) {
$ActualFileName = date("YmdHis") . $index . "." . $FileName;
make it look like this...
while($file_exists) {
$ActualFileName = $FileName;
Your file will be uploaded and stored as the user sent it.
Remember EVERY time you regenerate the site you will need to re-edit this line.
I have a single script that performs a few items on a site like this which does
save me a lot of time.
|
|
|
solesz
Posts: 137
|
Posted: 10/17/2012, 5:42 AM |
|
aewhite901:
According to my knowledge the situation is quite dangerous. During full regeneration this section of the file won't be regenerated at all. I use this kind of method on everyday basis, but if you put your own code within ccs secured area, that area will contain your code forever.
I think it is better, to copy the file upload routine outside, and make the whole process independent from ccs. And even better to find your best upload routine ( I never say ccs upload routine bad, but has some drawback i.e. not handling the UTF characters in file name correctly)
|
|
|
bannedone
Posts: 273
|
Posted: 10/17/2012, 6:58 AM |
|
Hi
As I mentioned above it is not a good idea to keep thhe original file name. You will lose images in many situations.
However if you must do this for what ever reason, like only one person using your web site, both methods above scare me.
It is never a good idea to modify CCS generated code. It reneders your project un-maintainable by CCS.
The best way to do this would be in the After Process File event put some custom code that will rename the file and update the DB
Use this function to get the orginal file name to do so.
CCGetOriginalFileName($value)
_________________
John Real
CodeCharge Studio Support, Training, Consulting, Development, Web based solutions
http://realsites.biz
http://ccselite.com
Other Banned IDs on this Forum. jjrjr1, jjrjr2 |
|
|
MichaelMcDonald
Posts: 640
|
Posted: 10/17/2012, 8:00 AM |
|
After thinking about this some more, the CCS method of renaming the file with timestamp appears it could conceptually result in filename duplication - if more than one person uploaded at precisely the same time. As this operation is not a managed time slice, then I think such duplication could occur....
_________________
Central Coast, NSW, Australia.
|
|
|
bannedone
Posts: 273
|
Posted: 10/17/2012, 8:31 AM |
|
...
_________________
John Real
CodeCharge Studio Support, Training, Consulting, Development, Web based solutions
http://realsites.biz
http://ccselite.com
Other Banned IDs on this Forum. jjrjr1, jjrjr2 |
|
|
Lucius
Posts: 220
|
Posted: 10/17/2012, 9:56 AM |
|
Quote MichaelMcDonald:
After thinking about this some more, the CCS method of renaming the file with timestamp appears it could conceptually result in filename duplication - if more than one person uploaded at precisely the same time. As this operation is not a managed time slice, then I think such duplication could occur....
And they would have to upload a file named exactly the same... Not impossible, but not very likely.
Even if such case would happen then one user would get duplicate filename error. On second upload it would work fine.
I don't think it would be worth doing anything about this possibility code-wise. If you are working on some system dealing with many file uploads by multiple users you should anyway split uploaded files into different directories - one per user for example.
|
|
|
MichaelMcDonald
Posts: 640
|
Posted: 10/17/2012, 6:55 PM |
|
I suspect statistically the opportunity for it to occur lies well within a bell curve...
_________________
Central Coast, NSW, Australia.
|
|
|
|