Problem during overwrite the existing image

See all posts Reply

Problem during overwrite the existing image new!
by raheel, 18 years, 2 months ago
I set the parameter of overwrite as true but my application creates multiple images when i upload a same image.Reply
Re: Problem during overwrite the existing image new!
by colin, 18 years, 2 months ago
You set the parameter file_overwrite to true, but you also need to set file_auto_rename to false, otherwise it renames the picture by default. This is normal beahviour, since we want to avoid loosing images when simply using the default settings.

So try:
$foo->file_overwrite = true;
$foo->file_auto_rename = false;
Reply
Re: Problem during overwrite the existing image new!
by Jenifer, 18 years, 1 month ago
I've set file_overwrite to true and set the file_auto_rename to false, but receive this error when attempting to overwrite an existing image:

Error: Destination directory can't be made writeable. Can't carry on a process

I have the following set:
$handle->file_new_name_body = "my_file_name";
$handle->file_overwrite = true;
$handle->file_auto_rename = false;
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_x = 100;
$handle->jpeg_quality = 100;

It works great if I allow it to create a new filename and not overwrite the existing, but overwriting the existing file throws the error.

Any ideas on what may be causing this?
JeniferReply
Re: Problem during overwrite the existing image new!
by colin, 18 years, 1 month ago
Check if the destination file is writable, as well as the file you want to overwrite. Set the permissions to 777 to begin with.

Are you using the version 0.20 or the 0.21RC?Reply
Re: Problem during overwrite the existing image new!
by Jenifer, 18 years, 1 month ago
Well, the destination file is an image, so I'm limited as to what permissions that file can be set to. And, the directory is set to 777. I'm using version 0.20 that I grabbed off of phpclasses.org.

These files were originally uploaded to the directory using FTP. This scenerio works for some reason:

1. I delete the original FTPed image
2. I use your upload class to upload that image
3. I use your upload class to upload and overwrite the image in step #2.

I wonder why this would be different than just using your upload class to overwrite the FTPed image? I checked all of the images in the directory and they all have the same apparent permissions checked (0644). Both the images FTPed and the images uploaded using the class.

Very odd...
JeniferReply
Re: Problem during overwrite the existing image new!
by colin, 18 years, 1 month ago
Yes, it's a bit strange. Maybe the file uploaded via FTP is owned by a different user than the one under which PHP is running.

Try version 0.21, there are more checks for the file permissions and overwriting.Reply
Re: Problem during overwrite the existing image new!
by Jenifer, 18 years, 1 month ago
Unfortunately, the same error message appears. We are in the process of moving everything to a new web server as well, so this problem has a chance of disappearing at that point. Until then, I can just unlink/delete the original file before uploading the new one for now.Reply
Re: Problem during overwrite the existing image new!
by Martin, 17 years, 11 months ago
I am not too sure here but i may have found a solution to your problem. I have been experiencing the same problem when i moved a domain over to another server for testing. I could add new images but not overwrite existing ones. This was with the same script used on the other domain.

After much testing the only way i could make it work was to chmod the images folder for the uploaded folder to 777 like before but also all the original files in it also. The with full permissions the overwrite feature works. Once the script has uploaded the image or overwritten it the permissions are set to 644 like before. I dont know what security risks are at threat if there are any but i will keep a note if this happens again.

In theory if all products were eventually updated on the server the file permission will eventually go back to 644.

I dont know if this has anything to do with what was mentioned about about the web server permissions but if this helps then great.Reply