Upload file/image versioning

P

PLMresearch

Guest
Running DaDaBIK version 2.2.1 released; New feature: When two or more files with the same name are uploaded, a new name is assigned automatically (e.g. my_file.txt become my_file_2.txt if my_file.txt already exists, my_file_3 if also my_file_2 already exists and so on).

Maybe it was just me, but I had to modify the code (somewhere around line 1115) to the following:
$file_name_new = get_valid_name_uploaded_file($file_name);
$sql .= "'".$file_name_new."', "; // add the field value to the sql statement
// rename the temp name of the uploaded file
copy ($upload_directory.'dadabik_tmp_file_'.$file_name, $upload_directory.$file_name_new);
unlink($upload_directory.'dadabik_tmp_file_'.$file_name);


Hope this helps
 
E

Eugenio

Guest
PLMresearch wrote:
>
> Running DaDaBIK version 2.2.1 released; New feature: When
> two or more files with the same name are uploaded, a new name
> is assigned automatically (e.g. my_file.txt become
> my_file_2.txt if my_file.txt already exists, my_file_3 if
> also my_file_2 already exists and so on).
>
> Maybe it was just me, but I had to modify the code (somewhere
> around line 1115) to the following:

[......]

Uhm, why have you changed $file_name with $file_name_new?
Where was the problem?

Eugenio.

(Latest version of DaDaBIK when this message was posted: 2.2.1)
 
P

PLMresearch

Guest
Sorry, I didn't explain my changes well. I added a new file name variable ($file_name_new) to hold the the new, automatically assigned name while still preserving the name of the file on my local machine.

If I did not do this, the script would generate a new name, like images_2.jpg and then try to upload that file from my machine. The local file is called images.jpg _not_ images_2.jpg and therefore would result in throwing off an error.

My change seems to work without a hitch. Hope I've done a reasonable job explaining it. Let me know if otherwise.
 
E

Eugenio

Guest
PLMresearch wrote:
>
> Sorry, I didn't explain my changes well. I added a new file
> name variable ($file_name_new) to hold the the new,
> automatically assigned name while still preserving the name
> of the file on my local machine.
>
> If I did not do this, the script would generate a new name,
> like images_2.jpg and then try to upload that file from my
> machine. The local file is called images.jpg _not_
> images_2.jpg and therefore would result in throwing off an
> error.

I miss the point.
If DaDaBIK generate a new name, e.g. image_2.jpg, and on the client the file is called image.jpg where is the problem? If I want to upload again my image.jpg file I can, when I get the error?

Eugenio.

(Latest version of DaDaBIK when this message was posted: 2.2.1)
 
P

PLMresearch

Guest
Without my fix, Dadabik was looking for the new file name on the client (e.g. image_2.jpg) and then - correctly - told me that no such file existed.

With my fix, Dadabik looked for the original file name on the client (e.g. image.jpg) and then renamed that file to image_2.jpg when it wrote to the directory on the server.

Does this explanation make more sense?
 
E

Eugenio

Guest
PLMresearch wrote:
>
> Without my fix, Dadabik was looking for the new file name on
> the client (e.g. image_2.jpg) and then - correctly - told me
> that no such file existed.

DaDaBIK never looks at the client side, only when the client want to upload a *new* file, but in this case the old file name is ininfluent. Isn't it?

Eugenio.
 
P

PLMresearch

Guest
It appeared to me that Dadabik (or perhaps IE 6.0.28) looked in the client (my computer) directory for the new, Dadabik assigned, name (e.g. image_2.jpg). It could not find such a file name, and threw off an error indicating such.

By implementing my fix, Dadabik (or perhaps IE 6.0.28) looked in the client (my computer) directory for the origninal file name (e.g. image.jpg) and then wrote that file as the new, Dadabik assigned, name (e.g. image_2.jpg) into the host directory.
 
E

Eugenio

Guest
PLMresearch wrote:
>
> It appeared to me that Dadabik (or perhaps IE 6.0.28) looked
> in the client (my computer) directory for the new, Dadabik
> assigned, name (e.g. image_2.jpg). It could not find such a
> file name, and threw off an error indicating such.
>
> By implementing my fix, Dadabik (or perhaps IE 6.0.28) looked
> in the client (my computer) directory for the origninal file
> name (e.g. image.jpg) and then wrote that file as the new,
> Dadabik assigned, name (e.g. image_2.jpg) into the host
> directory.

I have just tried it with IE 6.0.28 with no problems, DaDaBIK never looks on the client side, the file name changes only on the server side, and there the hypotetic image_2.jpg file really exists.

Eugenio.

(Latest version of DaDaBIK when this message was posted: 2.2.1)
 
E

Eugenio

Guest
PLMresearch wrote:
>
> It appeared to me that Dadabik (or perhaps IE 6.0.28) looked
> in the client (my computer) directory for the new, Dadabik
> assigned, name (e.g. image_2.jpg). It could not find such a
> file name, and threw off an error indicating such.

Any other users had experienced problems with the rename feature of DaDaBIK upload?

Eugenio.

(Latest version of DaDaBIK when this message was posted: 2.2.1)
 
P

PLMresearch

Guest
Thanks. Could just be the configuration at my ISP or some other peculiarity. I appreciate your follow up. Please let me know if I can assist in any way with your project. Really a great one!
 
P

PLMresearch

Guest
It would be my pleasure to help you out with the support issues. Please let me know how you intend to parse out the questions and any other information necessary to assist. BTW - I'm developing in a WAMP environment, but running in a FAMP (FreeBSD) environment.

Awaiting your reply.
 
Top