![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 | |
Confirmed User
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,188
|
![]() Quote:
I've tried this, which i thought would work but didnt: [quote] $imageFileType rename(2.'$imageFileType'); [quote] ![]()
__________________
Extreme Link List - v1.0 |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 | |
Industry Role:
Join Date: Aug 2006
Location: Little Vienna
Posts: 32,235
|
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Confirmed User
Industry Role:
Join Date: Apr 2019
Posts: 657
|
1. Rename all files on upload for security, control and so you don't get dupes in the first place.
2. No idea about the clickable thing, since as usual you don't explain things properly. How are you viewing it, in a directory index listing, hrefs, img src, something else?
__________________
__________________ |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 | ||
Confirmed User
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,188
|
Quote:
Quote:
__________________
Extreme Link List - v1.0 |
||
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Confirmed User
Industry Role:
Join Date: Aug 2006
Location: Poland
Posts: 9,228
|
What about just prepending uniqid() to the start or end of the existing filename?
__________________
Mechanical Bunny Media Mechbunny Tube Script | Mechbunny Webcam Aggregator Script | Custom Web Development |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
Confirmed User
Industry Role:
Join Date: Apr 2019
Posts: 657
|
Why? If you're having to rename files if they exist, it can't be that important for them to strictly match the original name.
The files are effectively renamed when you upload anyway, when they're in the tmp directory, and when you move them from tmp you're 'renaming' them back to the original name, so instead you just pick a new unique name that you control that won't clash. Anyway, if there's still some reason you can't do that, here's a basic code illustrating renaming of an uploaded file only if it exists. Save it as a PHP file and try it. Obviously change $up_dir to whatever you're using. Code:
<?php $up_dir = 'upload/'; $tmp_name = $_FILES["image"]["tmp_name"]; $name = basename($_FILES["image"]["name"]); if (file_exists($up_dir.$name)) { // rename file however you like, eg: $name = $name.'_'.time(); } move_uploaded_file($tmp_name, $up_dir.$name); ?> <form enctype="multipart/form-data" action="" method="post"> <input type="file" name="image"> <input type="submit" value="Upload"> </form>
__________________
__________________ |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() ![]() |
|||||||
|
|||||||
Bookmarks |
Thread Tools | |