ButtLord420
Please delete my devbest account.
- Dec 11, 2010
- 463
- 32
Hi Devbest,
I am making a new upload script but I want to make it so that when users upload a file it adds random characters to it
EG: image.png would maybe be 6fjs8fj654f.png
Here is the script that I am using that uploads the files normaly.
Thanks,
Jamz
I am making a new upload script but I want to make it so that when users upload a file it adds random characters to it
EG: image.png would maybe be 6fjs8fj654f.png
Here is the script that I am using that uploads the files normaly.
PHP:
<?php
/*
|-----------------
| Chip Error Manipulation
|------------------
*/
error_reporting(-1);
/*
|-----------------
| Chip Constant Manipulation
|------------------
*/
define( "CHIP_DEMO_FSROOT",__DIR__ . "/" );
/*
|-----------------
| POST
|------------------
*/
if( $_POST ) {
/*
|-----------------
| Chip Upload Class
|------------------
*/
require_once("class.chip_upload.php");
/*
|-----------------
| Upload(s) Directory
|------------------
*/
$upload_directory = CHIP_DEMO_FSROOT . "uploads/";
/*
|-----------------
| Class Instance
|------------------
*/
$object = new chip_upload();
/*
|-----------------
| $_FILES Manipulation
|------------------
*/
$files = $object->get_upload_var( $_FILES['upload_file'] );
//$object->chip_print( $files );
/*
|-----------------
| Upload File
|------------------
*/
foreach( $files as $file ) {
/*
|---------------------------
| Upload Inputs
|---------------------------
*/
$args = array(
'upload_file'=>$file,
'upload_directory'=>$upload_directory,
'allowed_size'=>512000,
'extension_check'=>FALSE,
'upload_overwrite'=>FALSE,
);
$allowed_extensions = array(
'pdf'=> TRUE,
);
/*
|---------------------------
| Upload Hook
|---------------------------
*/
$upload_hook = $object->get_upload( $args, $allowed_extensions );
//$object->chip_print( $upload_hook );
//exit;
/*
|---------------------------
| Move File
|---------------------------
*/
if( $upload_hook['upload_move'] == TRUE ) {
/*
|---------------------------
| Any Logic by User
|---------------------------
*/
/*
|---------------------------
| Move File
|---------------------------
*/
$upload_output[] = $object->get_upload_move();
//$object->chip_print( $upload_output );
} else {
/*$temp['uploaded_status'] = FALSE;
$temp['uploaded_file'] = $upload_hook['upload_file']['name'] ;
$upload_output[] = $temp;*/
}
} // foreach( $files as $file )
} // if( $_POST )
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" media="all" href="style.css" />
<title>MyFi.le</title>
</head>
<body>
<strong></strong>
<div id="wrap">
<div id="wrapdata">
<div id="header">
<div id="headerdata">
<div class="chipboxw1 chipstyle1">
<div class="chipboxw1data">
<h2 class="margin0">Myfi.le</h2>
</div>
</div>
</div>
</div>
<div id="content">
<div id="contentdata">
<?php if( !empty($upload_output) ): ?>
<?php
//$object->chip_print( $upload_output );
foreach( $upload_output as $val ):
?>
<div class="chipboxw1 chipstyle2">
<div class="chipboxw1data">
<h2 class="margin0"><?php echo $val['uploaded_file'] . "." . $val['uploaded_extension'] . " was uploaded"; ?></h2>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
<div class="chipboxw1 chipstyle1">
<div class="chipboxw1data">
<form method="post" action="" enctype="multipart/form-data">
<p>Upload File 1: <input name="upload_file[]" id="upload_file[]" type="file" class="inputtext" /></p>
<p>Upload File 2: <input name="upload_file[]" id="upload_file[]" type="file" class="inputtext" /></p>
<p>Upload File 3: <input name="upload_file[]" id="upload_file[]" type="file" class="inputtext" /></p>
<p>Upload File 4: <input name="upload_file[]" id="upload_file[]" type="file" class="inputtext" /></p>
<p>Upload File 5: <input name="upload_file[]" id="upload_file[]" type="file" class="inputtext" /></p>
<p><a href="whatcaniupload.php">What can I upload?</a></p>
<input type="submit" name="submit" value="Upload File" />
</form>
</div>
</div>
</div>
</div>
<div id="footer">
<div id="footerdata">
<div class="chipboxw1 chipstyle1">
<div class="chipboxw1data">
© MyFi.le by James (Jamz) Dale.</a>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Thanks,
Jamz