Jump to content

Recommended Posts

When i used this it randomized the name but it doesnt randomize the file name so it tells the url thats the file doesnt exist

[code]<?php
$maxfilesize = "524288";
if($_FILES['userfile']['size'] > $maxfilesize){
echo "File Size To Big Sorry Pick a Smaller File Size current is".$_FILES['userfile']['size']."0.5 megabyte Allowed Only or 512 kilobyte";
exit();
}
$dir = "images/";
if(file_exists($dir.$_FILES['userfile']['name'])){
die("Theirs a file already named after that");
exit();
}
$file_type = array("application/x-javascript","image/gif","image/pjpeg","text/plain","image/png","image/jpeg","image/bmp");
$name = substr(md5(mt_rand()), 5, 10) . substr($_FILES['thefile']['name'], -4);
if(in_array($_FILES['userfile']['type'],$file_type)){
if(!(copy($_FILES['userfile']['tmp_name'], "images/" . $_FILES['userfile']['name']))) die("Cannot upload files.");
echo "Upload Complete!<br>";
echo "<a href='"."http://xizionz.vectoredhost.com/images/"."$name"."'>"."Here"."</a>";
}else{
die("Sorry We Dont Execpt that file type");
}
?>[/code]

so how can i rename the file when its uploaded 2 the servers.
Link to comment
https://forums.phpfreaks.com/topic/14659-randomly-rename-files-when-uploaded/
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.