Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/O Code)
 Upload mod ; check if file exists
 New Topic  Reply to Topic
 Printer Friendly
Previous Page | Next Page
Author Previous Topic Topic Next Topic
Page: of 3

AnonJr
Moderator

United States
5768 Posts

Posted - 02 May 2006 :  21:30:29  Show Profile  Visit AnonJr's Homepage  Reply with Quote
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?<
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 03 May 2006 :  03:02:06  Show Profile  Visit MarcelG's Homepage  Reply with Quote
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
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 03 May 2006 :  03:28:24  Show Profile  Visit HuwR's Homepage  Reply with Quote
so, if you already have the answer, why are you asking the question ?<
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 03 May 2006 :  03:33:36  Show Profile  Visit HuwR's Homepage  Reply with Quote
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<
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 03 May 2006 :  03:42:38  Show Profile  Visit MarcelG's Homepage  Reply with Quote
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
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 03 May 2006 :  03:49:13  Show Profile  Visit HuwR's Homepage  Reply with Quote
MarcelG, as I said, it is the PHP doing the checking
<

Edited by - HuwR on 03 May 2006 03:50:55
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 03 May 2006 :  04:06:42  Show Profile  Visit MarcelG's Homepage  Reply with Quote
Okay...I'll just give up then.
Thanks for the feedback.<

portfolio - linkshrinker - oxle - twitter
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 03 May 2006 :  04:15:56  Show Profile  Visit HuwR's Homepage  Reply with Quote
why can't you just use the upload code you have at storage.oxle.com ?
<
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 03 May 2006 :  05:08:06  Show Profile  Visit MarcelG's Homepage  Reply with Quote
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
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 03 May 2006 :  05:40:48  Show Profile  Visit HuwR's Homepage  Reply with Quote
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<
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 03 May 2006 :  08:33:42  Show Profile  Visit AnonJr's Homepage  Reply with Quote
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. <
Go to Top of Page

Todd
New Member

USA
63 Posts

Posted - 03 May 2010 :  20:24:55  Show Profile  Visit Todd's Homepage  Reply with Quote
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

Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 04 May 2010 :  02:35:31  Show Profile  Visit HuwR's Homepage  Reply with Quote
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
Go to Top of Page

Classicmotorcycling
Development Team Leader

Australia
2084 Posts

Posted - 04 May 2010 :  05:08:56  Show Profile  Reply with Quote
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
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 04 May 2010 :  11:14:35  Show Profile  Visit HuwR's Homepage  Reply with Quote
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
Go to Top of Page
Page: of 3 Previous Topic Topic Next Topic  
Previous Page | Next Page
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.21 seconds. Powered By: Snitz Forums 2000 Version 3.4.07