Jump to content

[SOLVED] uploading images through php form


soycharliente

Recommended Posts

You could use file_exists to validate the upload

 

<?php
$filename = '/path/to/foo.txt';

if (file_exists($filename)) {
    print "$filename exists";
} else {
    print "Het bestand $filename does not exists";
}
?> 

Link to comment
Share on other sites

add the current time after your image, this way the image never will have the same name and never will be overwritten

 

// 1. seperate the file to: array ( 'file', 'ext' )

// 2. gleu it together using: _123456.

// 3. result: file_123456.ext

 

$file = implode('_'.time().'.', explode('.', $_FILES['uploadname']['name']));

 

// only usable under file.ext condition, if you need a more complicated version pm me

Link to comment
Share on other sites

1. nope, you don't have to change the filename, but when it exists it will be overwritten (btw: when using file_exists() results are cached, use clearstatcache() to clear the buffer)

2. time() gives the current time and will never be the same because it keeps counting up... (unless you can time travel)

3. done.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.