Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $findex = "upld";
- $newname = uniqid($findex . "_");
- // A list of permitted file extensions
- $allowed = array('png', 'jpg', 'gif','tiff' , 'pdf' , 'zip' , 'docx' , 'doc' , 'mp3' , 'avi' , 'mov' , 'mp4' , 'mkv' , 'zip' , 'rar');
- if(isset($_FILES[$findex]) && $_FILES[$findex]['error'] == 0){
- $extension = pathinfo($_FILES[$findex]['name'], PATHINFO_EXTENSION);
- $base = pathinfo($_FILES[$findex]['name'], PATHINFO_FILENAME);
- $newname = $base . "_" . uniqid() . "." . $extension;
- /*if(!in_array(strtolower($extension), $allowed)){
- echo '{"status":"error"}';
- exit;
- }
- */
- if(move_uploaded_file($_FILES[$findex]['tmp_name'], 'uploads/'. $newname )){
- // add to picture list
- // add pocture list id to bids table
- echo '{"status":"success" , "newname" : "'.$newname.'"}';
- exit;
- }
- }
- echo '{"status":"error"}';
- exit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement