Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unlink works sometimes

Status
Not open for further replies.

phpgramma

Programmer
Dec 24, 2004
35
0
0
US
I have a script that uses the same filename over and over again for uploads. For example: pic1.jpg, pic2.jpg, picn.jpg where n is an auto_id from the database corresponding to the user.

The script takes a file upload from the user, deletes the old picn.jpg, and then uses move_uploaded_file() to write in the new pic with the same name.

Problem: unlink doesn't work when the whole script runs altogether. In trying to debug, I stopped the script (die()) after unlink()ing and it worked without fail every time. But then I took the die() command back out and it stopped working.

Any ideas??

Code:
if (is_uploaded_file($_FILES['large']['tmp_name'])) {
			$pic=$_POST['oldlarge'];
			$result=@unlink($pic);
		$result=isValid($_FILES,"large");  //isValid() checks for jpegs only
		if ($result==0) {
			$whereto=$_FILES['large']['name'];
			$whereto2=$table.$record_id.".jpg";
			
			move_uploaded_file($_FILES['large']['tmp_name'],$root_dir."/".$o[$piclocation]."/".$whereto2) or print("Couldn't upload files.");
.
.
.

 
ah ha! I just figured out that the images themselves are okay, but I was using IE and it was just displaying the file in the Cache. Problem solved (after 2 hours! always something stupid....)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top