i have created a file uploading system on a website that i have created and i need to know how the file can be over written.

the file thats are upload are only used once and the next time the user uploads a new file i want the last file to be over written. the code i am using to name the file on the server is this.

$image_name=image1.'.'.$extension;

i no some a if statement will have to be placed in but when i tried to code it it stopped the upload working. i was using a unix time stamp at first but if i name the image it makes it easier for the image to be used in other sections of the site and for email purposes.

i am using something like this

<?	if (isset($_FILES['uploadingfile']['tmp_name'])) {
		$originalpath="http://www.wesite.com/".$_FILES['uploadingfile']['name'];
		if (!file_exists($uploaddir)) {
		  mkdir($uploaddir,0777);
		}  
		if(is_uploaded_file($_FILES['uploadingfile']['tmp_name']))
		{
		move_uploaded_file($_FILES['uploadingfile']['tmp_name'],.$_FILES['uploadingfile']['name']);
		}
		//update query
	}

?>
<form name="frmresumeupload" enctype="multipart/form-data" method="POST">
File: <input type="file" name="uploadingfile" size="30"> <br />
<input type="submit" value="Upload!">
</form>

thanks for the reply i should get it working now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.