Author |
Topic |
AnonJr
Moderator
United States
5768 Posts |
Posted - 02 May 2006 : 21:30:29
|
How is that different from using the FileSystem object? Don't you still have to do the whole round-trip with either scripting language? Or is the lack of sleep getting to me?< |
|
|
MarcelG
Retired Support Moderator
Netherlands
2625 Posts |
Posted - 03 May 2006 : 03:02:06
|
quote: Originally posted by HuwR
quote: Originally posted by AnonJr
What's available in PHP that makes the difference?
the ability to check if a file exists on the server
Sorry HuwR, but the page my browser is using is HTML, and all the browser does is execute some javascript. The CheckFileExist javascript function I posted at oxle is completely clientside....or not?
// Check if a file exists and update the status
function checkFileExists ( sFile, sFolder )
{
var xmlhttp = getXMLHttpObject ( );
if ( xmlhttp && fileExistStat && sFile != '' )
{
xmlhttp.onreadystatechange = function ( )
{
if ( xmlhttp.readyState == 4 )
{
if ( xmlhttp.status == 200 )
{
fileExistStat.innerHTML += xmlhttp.responseText;
fileExistStat.style.display = fileExistStat.innerHTML == '' ? 'none' : 'block';
}
}
}
xmlhttp.open ( 'GET', 'upload.php?action=checkfile&folder=' + sFolder + '&file=' + escape ( sFile ), true );
xmlhttp.send ( null );
}
} Or is that red line responsible for checking if the file exists? < |
portfolio - linkshrinker - oxle - twitter |
Edited by - MarcelG on 03 May 2006 03:27:41 |
|
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 03 May 2006 : 03:28:24
|
so, if you already have the answer, why are you asking the question ?< |
|
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 03 May 2006 : 03:33:36
|
quote: Originally posted by AnonJr
How is that different from using the FileSystem object? Don't you still have to do the whole round-trip with either scripting language? Or is the lack of sleep getting to me?
Ok, it is very simple to check if a file exists on the server using the fso, it is not possible however to check if the file you are about to upload exists because you need to post the form first before you can get at the filename, you can get at the filename using clientside javascript but you can't check if it exists on the server using clientside javascript, PHP does not have this security restriction< |
|
|
MarcelG
Retired Support Moderator
Netherlands
2625 Posts |
Posted - 03 May 2006 : 03:42:38
|
quote: Originally posted by HuwR
so, if you already have the answer, why are you asking the question ?
Well...sorry for trying to understand this....
I've been looking into upload.php, to see what it does when it's requested as mentioned in the red part. it then does this:
{
$files = gpc ( 'files', 'P', array() );
$folder = path_decode ( gpc ( 'folder', 'P', '' ) );
$path = $user_root . $folder . '/';
for ( $i = 0; $i < count ( $files ); ++$i )
{
if ( is_file ( $path . $files[$i] ) )
{
print parse ( $lang_upload['upl_file_exists_warn'], array ( '{file}' => htmlentities ( $files[$i] ), '{folder}' => ( $folder == '' ? $lang_misc['main_folder'] : basename ( $folder ) ) ) );
}
}
} < |
portfolio - linkshrinker - oxle - twitter |
|
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 03 May 2006 : 03:49:13
|
MarcelG, as I said, it is the PHP doing the checking < |
Edited by - HuwR on 03 May 2006 03:50:55 |
|
|
MarcelG
Retired Support Moderator
Netherlands
2625 Posts |
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 03 May 2006 : 04:15:56
|
why can't you just use the upload code you have at storage.oxle.com ? < |
|
|
MarcelG
Retired Support Moderator
Netherlands
2625 Posts |
Posted - 03 May 2006 : 05:08:06
|
Well, the code I'm looking for should 'plug in' to the Snitz file attachment mod. So, ASP Upload and ASP.< |
portfolio - linkshrinker - oxle - twitter |
|
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 03 May 2006 : 05:40:48
|
some of the asp upload components may have the ability to check, although they may still do the upload first, but do it to memory rather than to disk, you could still try to integrate the php upload form in to Snitz, alternatively you could write a .net upload component which did it all for you and integrate that in to Snitz< |
|
|
AnonJr
Moderator
United States
5768 Posts |
Posted - 03 May 2006 : 08:33:42
|
quote: Originally posted by HuwR
Ok, it is very simple to check if a file exists on the server using the fso, it is not possible however to check if the file you are about to upload exists because you need to post the form first before you can get at the filename, you can get at the filename using clientside javascript but you can't check if it exists on the server using clientside javascript, PHP does not have this security restriction
Way past time for me to start learning some PHP... thanks. I'm still not sure I understand the mechanics of how PHP gets the file name before you upload the file, but I'm willing to let it be ... until I get some basic PHP skills down. < |
|
|
Todd
New Member
USA
63 Posts |
Posted - 03 May 2010 : 20:24:55
|
Hi,
I'm wondering if this has ever been resolved. I'm using proeders file attachment mod to upload photos. More and more I'm having users upload photos with filenames they have already used. It's careless on their part but I would like a way to stop them from doing this. |
Admin for the Tyco Collector's Forum
|
|
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 04 May 2010 : 02:35:31
|
As per my previous post it is not possible to check prior to uploading the file, so the easisest thing to do would be to append the datetime stamp on the end of any filename saved, then you can't overwrite anything. |
MVC .net dev/test site | MVC .net running on Raspberry Pi |
|
|
Classicmotorcycling
Development Team Leader
Australia
2084 Posts |
Posted - 04 May 2010 : 05:08:56
|
According to the outputFile.asp (line 79) the file is saved with the current Year, Month, Day, Hour, Minute and Second at the front of the filename that is uploaded, which in my books would give it a different name each time a file is uploaded.
filename = Year(Now) & Month(Now) & Day(Now) & Hour(Now) & Minute(Now) & Second(Now) & "_" & filename
Maybe change the line to read:
filename = DateToStr(DateAdd("h", dtDateTime, strForumTimeAdjust)) & "_" & filename
Let me know how you go. |
Cheers, David Greening |
|
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 04 May 2010 : 11:14:35
|
quote: Originally posted by Classicmotorcycling
According to the outputFile.asp (line 79) the file is saved with the current Year, Month, Day, Hour, Minute and Second at the front of the filename that is uploaded, which in my books would give it a different name each time a file is uploaded.
yep, should do, so maybe it was resolved |
MVC .net dev/test site | MVC .net running on Raspberry Pi |
|
|
Topic |
|