PHP - Need Help Intergrating Uploader Into Forum Software
I Need help Integrating An Video Upload System Into The Mybb Forum Software. I understand You Need ffmeg +jwplayer ive already installed that on my server.But Now I Need A Little Help Integrating And Uploader Into The Software, So It Can Post The Video Into An Thred When My Users Upload.
Similar TutorialsThis topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=306605.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=347431.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=342157.0 Quote Hello, Am a newbie using PEAR packages in my coding. I installed smarty on XAMPP recently and followed the configuration process in the 'php.ini' file, labelling the path to the '\libs\' directory. Before installation of smarty, my pear packages were working fine, never received any errors. However, after installing smarty and including my template file 'config.php' with 'Auth/HTTP.php' within the same file, i gor these errors; Warning: require_once(Auth/HTTP.php) [function.require-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\OReilly\pear\blog\login.php on line 10 Fatal error: require_once() [function.require]: Failed opening required 'Auth/HTTP.php' (include_path='.;C:\xampp\smarty\libs') in C:\xampp\htdocs\OReilly\pear\blog\login.php on line 10 Warning: Cannot modify header information. Headers already sent by C:\xampp\htdocs\OReilly\pear\blog\login.php on line 10 Anybody got ideas what i can do to correct this issue, thanks. I have attached my templates file 'config.php' and my login script, the one that allows users to login be fore they access results to the database called 'login.php' I have Swift/symfony mail installed and sample code setup. When I require_once to a working PHP page, the page becomes blank in a browser, If i remove it from the require the website works. Lints can't find any errors or syntax issues in the code. Its on gitlab. What should i do? Below is the page where I send an email out and the environment I am in Ubuntu PHP7 SwiftMail 6.0^
<?php require_once '/vendor/autoload.php'; session_start(); // Create the Transport $transport = (new Swift_SmtpTransport('localhost', 465)) ->setUsername(noreply@example.com) ->setPassword(password); // Create the Mailer using your created Transport $mailer = new Swift_Mailer($transport); function sendVerificationEmail($email, $token) { global $mailer; $body = '<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Test mail</title> </head> <body> <div class="wrapper"> <p>Thank you for signing up on our site. Please click on the link below to verify your account:.</p> <a href="https://tadoo.club/verify-email.php?token=' . $token . '">Verify Email!</a> </div> </body> </html>'; // Create a message $message = (new Swift_Message('Verify your email')) ->setFrom(noreply@example.com) ->setTo($email) ->setBody($body, 'text/html'); // Send the message $result = $mailer->send($message); ?>
Hey guys I've made a php uploader, <form enctype="multipart/form-data" action="upload.php" method="POST"> Please choose a file: <input name="uploaded" type="file" /><br /> <input type="hidden" name="sent"/> <input type="submit" value="Upload" /> <?php /** * @author Jragon * @copyright 2010 */ function stringrand() { for ($i = 0; $i < 6; $i++) { switch (rand(1, 3)) { case 1: $rand .= chr(rand(48, 57)); break; //0-9 case 2: $rand .= chr(rand(65, 90)); break; //A-Z case 3: $rand .= chr(rand(97, 122)); break; //a-z } } return $rand; } if (isset($_POST['sent'])) { switch ($_FILES['uploaded']['name']) { case 'image/jpeg': $type = 'image'; $ext = 'jpg'; break; case 'image/gif': $type = 'image'; $ext = 'gif'; break; case 'image/png': $type = 'image'; $ext = 'png'; break; case 'video/mp4': $type = 'video'; $type = 'mp4'; break; case 'application/x-shockwave-flash': $type = 'video'; $ext = 'flv'; break; case 'audio/mp3': $type = 'audio'; $ext = 'mp3'; break; default: $type = ''; break; } if ($type == 'video') { $name = basename($_FILES['uploaded']['name']); $target = "/upload/$type/"; $target = $target . stringradnd() . ".$ext"; $worked = false; if (move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file " . $name . " has been uploaded"; $worked = true; } else { echo "Sorry, there was a problem uploading your file."; } } elseif ($type == 'audio') { $name = basename($_FILES['uploaded']['name']); $target = "/upload/$type/"; $target = $target . stringradnd() . ".$ext"; $worked = false; if (move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file " . $name . " has been uploaded"; $worked = true; $target = $target . "&plugins=revolt-1"; } else { echo "Sorry, there was a problem uploading your file."; } } elseif ($type == 'image') { $name = basename($_FILES['uploaded']['name']); $target = "/upload/$type/"; $target = $target . stringradnd() . ".$ext"; $worked = false; if (move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file " . $name . " has been uploaded"; $worked = true; } else { echo "Sorry, there was a problem uploading your file."; } } elseif ($type == '') { $worked = false; echo "Sorry the only extensions you can use a jpeg jpg gif png mp3 mp4 flv"; } if ($worked == true) { echo <<< ENDHTML <script type='text/javascript' src='/flvplayer/swfobject.js'></script> <div id='mediaspace'>This text will be replaced</div> <script type='text/javascript'> var so = new SWFObject('/flvplayer/player.swf','mpl','470','320','9'); so.addParam('allowfullscreen','true'); so.addParam('allowscriptaccess','always'); so.addParam('wmode','opaque'); so.addVariable('file','/upload/{$name}'); so.write('mediaspace'); </script> ENDHTML; } } ?> But its not working, it dosent upload the files Please help Jragon i am build am url image uploader he only problem i am having is take the url form the forum and placeing it in this code $content = file_get_contents('$img '); file_put_contents('/home/sambobi/public_html/bob/b_images/$id.jpg', $content); the variable $img is the url variable and the $id is random numbers and letter but both parts of this wont works can any one help All I want to do is upload an image to my images folder, which is on the site root, so mysite.com/images here is my code: Code: [Select] <form action="uploadimage.php" method="post" enctype="multipart/form-data" name="form1" id="form1"> <p> <label>Choose image to upload <input type="file" name="image" id="image" /> </label> </p> <p> <label> <input type="submit" name="imageupload" id="imageupload" value="Upload Image" /> </label> </p> </form> <?php $imagename = "1testimage"; if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/png"))) move_uploaded_file ($_FILES["file"]["tmp_name"],"images/" . $imagename.".gif"); ?> Cn anyone see why this is not working/ I have chenged the permissions on my hosting account to read and write... This topic has been moved to Other Web Server Software. http://www.phpfreaks.com/forums/index.php?topic=348113.0 Ok this script works but it needs to do more. I need to resize the images that get uploaded to 300px to 300px because the images are way to big and then i need to add a if statement to send back to flash if the file is to small to upload so it will look best. so no file that is less then 300px by 300px can be uploaded. this script is doing two things One it uploads the picture to some username folder Two it inserts into the database where username. <?php include "../php/connect.php"; $username = $_POST['username']; $username = stripslashes($username); $username = mysql_real_escape_string($username); if(@!empty($_FILES)) { $_FILES['Filedata']['name'] = Relocate(utf8_decode($_FILES['Filedata']['name']),$username); $filepath = getcwd()."/".$_GET['dir']."/"; if(!file_exists($filepath)) mkdir($filepath,0777); chmod($filepath,0777); if(move_uploaded_file($_FILES['Filedata']['tmp_name'], $filepath . $_FILES['Filedata']['name'])) chmod($filepath.$_FILES['Filedata']['name'], 0777); } function Relocate($str,$username) { $filename = "UserPhoto.jpg";//md5($str); $setavatar = mysql_query("UPDATE accounts SET avatar = 'http://wiistream.net/users/$username/images/$filename' WHERE username = '$username'"); echo '&msgText=' . $username . ''; return $filename; } Relocate($str,$username); ?> Hi I have this script which I hope to upload an image to my images folder and put the name of the image in my database along with what category it belongs too. I keep getting this error though.... Access denied for user 'websitename.co.uk'@'localhost' (using password: NO) Now when I check the server logs I get the following error to go with it... [Thu Dec 23 13:53:30 2010] [error] [client 0.0.0.0] PHP Warning: mysql_query() [<a href='function.mysql-query'>function.mysql-query</a>]: A link to the server could not be established in /home/sites/website name.co.uk/public_html/manage/upload.php on line 14, referer: http://www.websitename.co.uk/manage/add_image.php?cat='Robbers' Lie 14 is this... mysql_query("INSERT INTO `polaroids` VALUES ('$pic', '$category')") or die (mysql_error()); Ok so here is the code from the beginning. Ill start with the form its self.... <form enctype="multipart/form-data" action="upload.php" id="polaroidfrm" method="POST"> Please upload a PNG for the category <?php echo $_GET['cat']; ?>:<br> <input name="photo" type="file" size="40"/> </p> <br/> <input type="hidden" name="category" Value="<?php echo $_GET['cat']; ?>"> <input type="submit" value="Submit" name="insert_polaroid"> </form> then the upload page.... <?php //This is the directory where images will be saved $target = "images/polaroids/"; $target = $target . basename( $_FILES['photo']['name']); //This gets all the other information from the form $category=$_POST['catid']; $pic=($_FILES['photo']['name']); // Connects to your Database include('../../Connections/photoconnect.php'); session_start(); //Writes the information to the database mysql_query("INSERT INTO `polaroids` VALUES ('$pic', '$category')") or die (mysql_error()); //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //Tells you if its all ok $success = "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; $url = "polaroids.php?polaroidpass='".$success."'" or die(mysql_error()); header("Location: ".$url.""); } else { //Gives and error if its not $fail = "Sorry, there was a problem uploading your file."; $url = "polaroids.php?polaroidfail='".$fail."'" or die(mysql_error()); header("Location: ".$url.""); } ?> Trying to have my image uploader transfer up SWF files without any luck. It uploads the file name correctly but is not transferring the file itself to the file directory. It works fine with my regular images but just not with the SWF files. I've changed all occurences of JPG and replaced them with SWF. Help? Perhaps I'm missing something? Thanks for your help! Code: [Select] <?php $item_image = $_FILES['image_upload_box']['name']; $item_id = $_GET['id']; $sql="UPDATE imagetable SET sp_image='$item_image' WHERE id = '$item_id'"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } else { // upload the file if ((isset($_POST["submitted_form"])) && ($_POST["submitted_form"] == "image_upload_form")) { // file needs to be jpg,gif,bmp,x-png and 4 MB max if (($_FILES["image_upload_box"]["type"] == "image/swf" || $_FILES["image_upload_box"]["type"] == "image/pjpeg" || $_FILES["image_upload_box"]["type"] == "image/gif" || $_FILES["image_upload_box"]["type"] == "image/x-png") && ($_FILES["image_upload_box"]["size"] < 400000000)) { // some settings $max_upload_width = 800; $max_upload_height = 300; // if user chosed properly then scale down the image according to user preferances if(isset($_REQUEST['max_width_box']) and $_REQUEST['max_width_box']!='' and $_REQUEST['max_width_box']<=$max_upload_width){ $max_upload_width = $_REQUEST['max_width_box']; } if(isset($_REQUEST['max_height_box']) and $_REQUEST['max_height_box']!='' and $_REQUEST['max_height_box']<=$max_upload_height){ $max_upload_height = $_REQUEST['max_height_box']; } // if uploaded image was JPG/JPEG if($_FILES["image_upload_box"]["type"] == "image/swf" || $_FILES["image_upload_box"]["type"] == "image/swf"){ $image_source = imagecreatefromswf($_FILES["image_upload_box"]["name"]); } // if uploaded image was GIF if($_FILES["image_upload_box"]["type"] == "image/gif"){ $image_source = imagecreatefromgif($_FILES["image_upload_box"]["name"]); } // BMP doesn't seem to be supported so remove it form above image type test (reject bmps) // if uploaded image was BMP if($_FILES["image_upload_box"]["type"] == "image/bmp"){ $image_source = imagecreatefromwbmp($_FILES["image_upload_box"]["name"]); } // if uploaded image was PNG if($_FILES["image_upload_box"]["type"] == "image/x-png"){ $image_source = imagecreatefrompng($_FILES["image_upload_box"]["name"]); } $remote_file = "image_files/".$_FILES["image_upload_box"]["name"]; imagejpeg($image_source,$remote_file,100); chmod($remote_file,0644); // get width and height of original image list($image_width, $image_height) = getimagesize($remote_file); if($image_width>$max_upload_width || $image_height >$max_upload_height){ $proportions = $image_width/$image_height; if($image_width>$image_height){ $new_width = $max_upload_width; $new_height = round($max_upload_width/$proportions); } else{ $new_height = $max_upload_height; $new_width = round($max_upload_height*$proportions); } $new_image = imagecreatetruecolor($new_width , $new_height); $image_source = imagecreatefromswf($remote_file); imagecopyresampled($new_image, $image_source, 0, 0, 0, 0, $new_width, $new_height, $image_width, $image_height); imagejpeg($new_image,$remote_file,100); imagedestroy($new_image); } imagedestroy($image_source); MOD EDIT: [code] . . . [/code] BBCode tags added. Hi there I've been wanting to make a decent image uploader for a long time now. Here are the things that need to be able to be done: Select a whole folder of images, or a selection Each image must be rescaled twice, and every scaling must be renamed and put inside a seperate folder The new name of the image must be put in a database, and also the extension of the image And that's pretty much it... Ofcourse the biggest problem is the first one, since it cannot be done in PHP solely but it needs some javascript/ajax? I've never really worked with any plugins or so so I'm quite new to this, does anyone have a very easy one that I can easily adjust? Thanks in advance Does anyone have an image up-loader script that is easy to manipulate for the address, and renaming based upon the number in the file system the image is, or do I need to work on figuring it out on my own? Ok , so im fairly new to this beeen watching tuts , messing around with coding to see what does what , well i cant seem to get this uploader to send a image to the db it just errors the code is <html> <head> <title>Image Uploader</title> </head> <body> <form method="post" action="index.php" enctype="multipart/form=data"> File: <input type="file" name="image" /> <input type="submit" value="upload" /> </form> <?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("test") or die(mysql_error()); //file propities $file = $_FILES['image']['tmp_name']; if (!isset($file)) { echo "Please select an image"; } else { $image = file_get_contents ($_FILES['image']['tmp_name']); $image_name = $_FILES['image']['name']; $image_size = getimagesize($_FILES['image']['tmp_name']); if ($image_size==FALSE) echo "This is not an image file"; else { if (!$insert = mysql_query("INSERT INTO imagedb VALUES ('','$image_name','$image')")) echo "problem uploading image"; else { $lastid = mysql_insert_id(); echo "image uploaded<p>Your image</p><img scr =get.php?id=$lastid>"; } } } ?> </body> </html> thats my index.php then my get.php is <?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("test") or die(mysql_error()); $id = addslashes($_REQUEST['id']); $image = mysql_query("SELECT * FROM imagedb WHERE id=$id"); $image = mysql_fetch_assoc($image); $image = $image['image']; header("Content-type: img/jpeg"); echo $image; ?> My database is called 'test' and my table is called 'imagedb' and i have 3 fields 'id'name'image. help would be much appriciated thankyouu Hi. I have a piece of code that uploads an image. It works great. Ive added it to some more coding inserting information into a database. Now the code doesn't work. I have used some error reporting and i get Notice: Undefined index: newImage in /home/sites/submitpost.php on line 9 Notice: Undefined index: newImage in /home/sites/submitpost.php on line 10 Notice: Undefined index: newImage in /home/sites/submitpost.php on line 11 Notice: Undefined index: newImage in /home/sites/submitpost.php on line 12 Here is the code. Can someone explain whats wrong? include('database.php'); session_start(); //another photo uploader $fileName9 = $_FILES['newImage']['name']; $tmpName = $_FILES['newImage']['tmp_name']; $fileSize = $_FILES['newImage']['size']; $fileType = $_FILES['newImage']['type']; //$randName = md5(rand() * time()); //$fileName9 = $randName + $fileName9; $limit_size=2097152; $folder = "{$_SERVER['DOCUMENT_ROOT']}/images/memberImages/"; if ($fileSize >= $limit_size){$msg1="Your uploaded file size is more than 2MB so please reduce the file size and then upload. Visit the help page to know how to reduce the file size.<BR>"; $success=0;} elseif ($fileName9=="") {$error = "Please choose a file to upload"; $success=0;} //elseif ($fileType!== 'image/jpeg' || 'image/gif' || 'image/png' || 'image/JPG') {$error = "false";} $types = array('image/jpeg', 'image/gif', 'image/png', 'image/JPG', 'image/pjpeg', 'image/x-png'); if (in_array($fileType, $types)) { if(move_uploaded_file($tmpName , $folder.$fileName9)) { $Fnew1 = $fileName9; $place=mysql_real_escape_string($_POST['place']); $cityname=mysql_real_escape_string($_POST['cityname']); $city=mysql_real_escape_string($_POST['city']); $title=mysql_real_escape_string($_POST['ComTitle']); $message=mysql_real_escape_string($_POST['commentDescrip']); $member=mysql_real_escape_string($_POST['member']); $time=time(); mysql_query("INSERT INTO posts (type, title, message,postUserID, time, cityID, status, place, image) VALUES('$type','$title','$message','$member', '$time', '$city', '1', '$place', '$Fnew1')") or die('post error'); $id = mysql_insert_id(); $url = "/view-thankyou.php?city=$cityname&type=$type#name"; header("Location: $url"); } else {echo"Move fail"; } } ?> hello all, i have a photo uploader that clients use. i want this to be able to put clients photos in there own folder within a specified path. $(function() { $('#custom_file_upload').uploadify({ 'uploader' : '/uploadify.swf', 'script' : 'uploadify.php?user=<?php echo("$logged[ip]"); ?>', 'cancelImg' : '/cancel.png', 'folder' : '/wuploads/{$logged('email')}', 'multi' : true, 'auto' : true, 'fileExt' : '*.ZIP;*.zip;*.rar', 'queueID' : 'custom-queue', 'queueSizeLimit' : 1000, 'simUploadLimit' : 1000, 'removeCompleted': true, 'onSelectOnce' : function(event,data) { $('#status-message').text(data.filesSelected + ' files have been added to the queue.'); }, 'onAllComplete' : function(event,data) { $('#status-message').text(data.filesUploaded + ' files uploaded, ' + data.errors + ' errors.'); } }); }); i have tried the code above with 'folder' : '/wuploads/{$logged('email')}', but this doesnt seem to work, im new to php and tried a few different combinations but it wont budge! thanks, gavin Hi: I have written code that will allow a user to upload a file and that will allow the user to view/delete the image when clicking on the link. I'm having trouble in the table where the image information is organized - the table just duplicates information about an image into another column,.how can I fix this? Here's my code: Code: [Select] <? if ($handle = opendir('images/')) { while (false !== ($file = readdir($handle))) { $TPL['fileList'][] = array( 'fileName' => $file, 'fileSize' => filesize('images/'.$file), 'fileDate' => 'Jan 2, 2029' ); } } switch ($_REQUEST['act']): default: break; if (empty($_FILES['userfile']['name'])): $TPL['errMsg'] = "No file selected"; $TPL['dispErrMsg'] = true; break; endif; copy ($_FILES['userfile']['tmp_name'], 'images/'.$_FILES['userfile']['name']); break; case 'del': echo "delete this file? ($_GET)['userfile']['name']"; endswitch; ?> <html> <head> <title>Comp10065 - Lab 4: File Upload</title> <style type="text/css"> body {background-color:yellow} div#container {margin-right: auto; margin-left: auto; border: 1px solid #EEEEEE; width: 800px; padding: 10px; background-color:white} h1 {text-align: center; color:orange; background-color:white} table {width: 700px; margin-bottom: 15px} table th {text-align: left;padding: 0px 10 0px 10px} table td{padding: 0px 10 0px 10px; border: 1px solid #AAAAAA} tr.odd {background-color: #EEEEEE} tr.even {background-color: #CCCCCC} .message {color:red} div#debug {border: 1px solid #BBBBBB} </style> <script language="JavaScript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.js"></script> <script type="text/javascript"> function popup(img) { var day= new Date(); var windowParms = 'width=400,height=400,scrollbars,resizable'; var htmlPage = '<html><body><img src="' + img + '"><br>' + ' <form><input type="button" ' + ' onclick="javascript:window.close();" value="Close Window"><br>\n' + ' </form></body></html>\n'; var popupWindow = window.open('',day.getTime(),windowParms); popupWindow.document.write(htmlPage); popupWindow.document.close(); } </script> <script> $(function() { $("div#debug").hide(); $("a#debugLink").click(function () {$("div#debug").toggle("slowly"); }); }); </script> </head> <body > <div id="container"> <h1> Picture Uploader!</h1> <p>Click here to <a href="<?= $_SERVER['PHP_SELF'] ?>">refresh</a> this page.</p> <table> <tr> <th>File Name (<a href="upload.php?act=sortby&col=filename">sort</a>)</th> <th>Size KBytes (<a href="upload.php?act=sortby&col=size">sort</a>)</th> <th>Date</th> </tr> </td> <? foreach($TPL['fileList'] as $key => $val): ?> <td><a href="<?= 'images/'.$val['fileName'] ?>"><?=$val['fileName'] ?></a></td> <td><?= $val['fileName'] ?></td> <td><?= $val['fileSize'] ?></td> <td><?= $val['fileDate'] ?></td> <td><a href="#" onClick="popup('images/uieiuirdi.jpg')" >View</a></td> <td align=center><a href=upload.php?act=del&file=uieiuirdi.jpg>Delete</a></td> </tr> <? endforeach ?> </table> <p class="message">Records sorted by size</p> <form action=upload.php method="post" enctype='multipart/form-data'> <input type="hidden" name="MAX_FILE_SIZE" value="2000000"> <input type="hidden" name="act" value="post"> <input type="file" name="userfile" size="60" value=""> <br> <input type="submit" value="UPLOAD FILE" name="submit">Do not upload large files! </form> <? if($TPL['dispErrMsg']): ?> <p><?= $TPL['errMsg'] ?></p> <? endif; ?> <hr> <p>Click <a href="#" id = "debugLink"> here </a> for debug info. Jquery show/hide effect.</p> <div id="debug"> <p>This debug info is here to help you. You are only required to display the $_POST and $_FILES array</p> <pre > <? print_r($TPL) ?></pre> </div> </div> </body> </html> Hi, Ive had a website for some time that allows people to upload pictures to certain directories, and each directory had its own upload script, I decided as Im slowley getting better at php to combine it all into 1 file and include it, all works great, but now I notice its a lot of repeated code as the only thing that changes for each function is the directory name, here is the script as it is: <?php // James Davies, Revised 2010 // Create the main NSFW upload function function demotivate() { //configure site specific variables $website = 'http://www.thenudedeer.com'; //what is the folder name $phpbbdir = '/demotivate/'; // Create an array containing all valid upload file types for this script $allowed_types = array( "image/gif" => "gif", "image/pjpeg" => "jpg", "image/jpg" => "jpg", "image/jpeg" => "jpg", "image/png" => "png", "image/x-png" => "png", // Add more types here if you like ); // Check to see if the file type is in the allowed types array if(!array_key_exists($_FILES['userfile']['type'], $allowed_types)) { die("Invalid file type."); } // Set the maximum uploadable file size => 512000 = 500kb $maxfilesize = 512000; // Is the file larger than it is allowed to be? if($_FILES['userfile']['size'] > $maxfilesize) { die("File too large"); } // Where will the file be uploaded to? $uploaddir = $_SERVER['DOCUMENT_ROOT'] . $phpbbdir; // What is the files temporary name? $file = $_FILES['userfile']['tmp_name']; // What is the files actual name? $filename = $_FILES['userfile']['name']; // Does this file already exist on the server? if(file_exists($uploaddir . $filename)) { //die("A file with that name already exists on this server."); die("File already existed, [img]http://" . $website . $phpbbdir . $filename ."[/img]"); } else { // This file does not already exist, so copy it. copy($file, $uploaddir.$filename) or die("Could not copy file."); } // All done! :-) echo "<br />"; echo "<font color=red><b>"; echo "Upload successful"; echo "<br />"; echo "Copy and Paste the following Code"; echo "</font><br/>"; echo "<font color='green'><b>"; echo "<br />"; echo "[img]http://" . $website . $phpbbdir . $filename; echo "[/img]"; echo "<br/>"; echo "<br/>"; echo '<img class="img" src="' .$phpbbdir .$filename.'">'; echo "<br />"; echo "<br />"; echo "</font>"; echo "<br /><br />"; } function nsfw() { //configure site specific variables $website = 'http://www.thenudedeer.com'; //what is the folder name $phpbbdir = '/nsfw/'; // Create an array containing all valid upload file types for this script $allowed_types = array( "image/gif" => "gif", "image/pjpeg" => "jpg", "image/jpg" => "jpg", "image/jpeg" => "jpg", "image/png" => "png", "image/x-png" => "png", // Add more types here if you like ); // Check to see if the file type is in the allowed types array if(!array_key_exists($_FILES['userfile']['type'], $allowed_types)) { die("Invalid file type."); } // Set the maximum uploadable file size => 512000 = 500kb $maxfilesize = 512000; // Is the file larger than it is allowed to be? if($_FILES['userfile']['size'] > $maxfilesize) { die("File too large"); } // Where will the file be uploaded to? $uploaddir = $_SERVER['DOCUMENT_ROOT'] . $phpbbdir; // What is the files temporary name? $file = $_FILES['userfile']['tmp_name']; // What is the files actual name? $filename = $_FILES['userfile']['name']; // Does this file already exist on the server? if(file_exists($uploaddir . $filename)) { //die("A file with that name already exists on this server."); die("File already existed, [img]http://" . $website . $phpbbdir . $filename ."[/img]"); } else { // This file does not already exist, so copy it. copy($file, $uploaddir.$filename) or die("Could not copy file."); } // All done! :-) echo "<br />"; echo "<font color=red><b>"; echo "Upload successful"; echo "<br />"; echo "Copy and Paste the following Code"; echo "</font><br/>"; echo "<font color='green'><b>"; echo "<br />"; echo "[img]http://" . $website . $phpbbdir . $filename; echo "[/img]"; echo "<br/>"; echo "<br/>"; echo '<img class="img" src="' .$phpbbdir .$filename.'">'; echo "<br />"; echo "<br />"; echo "</font>"; echo "<br /><br />"; } function fail() { //configure site specific variables $website = 'http://www.thenudedeer.com'; //what is the folder name $phpbbdir = '/fail/'; // Create an array containing all valid upload file types for this script $allowed_types = array( "image/gif" => "gif", "image/pjpeg" => "jpg", "image/jpg" => "jpg", "image/jpeg" => "jpg", "image/png" => "png", "image/x-png" => "png", // Add more types here if you like ); // Check to see if the file type is in the allowed types array if(!array_key_exists($_FILES['userfile']['type'], $allowed_types)) { die("Invalid file type."); } // Set the maximum uploadable file size => 512000 = 500kb $maxfilesize = 512000; // Is the file larger than it is allowed to be? if($_FILES['userfile']['size'] > $maxfilesize) { die("File too large"); } // Where will the file be uploaded to? $uploaddir = $_SERVER['DOCUMENT_ROOT'] . $phpbbdir; // What is the files temporary name? $file = $_FILES['userfile']['tmp_name']; // What is the files actual name? $filename = $_FILES['userfile']['name']; // Does this file already exist on the server? if(file_exists($uploaddir . $filename)) { //die("A file with that name already exists on this server."); die("File already existed, [img]http://" . $website . $phpbbdir . $filename ."[/img]"); } else { // This file does not already exist, so copy it. copy($file, $uploaddir.$filename) or die("Could not copy file."); } // All done! :-) echo "<br />"; echo "<font color=red><b>"; echo "Upload successful"; echo "<br />"; echo "Copy and Paste the following Code"; echo "</font><br/>"; echo "<font color='green'><b>"; echo "<br />"; echo "[img]http://" . $website . $phpbbdir . $filename; echo "[/img]"; echo "<br/>"; echo "<br/>"; echo '<img class="img" src="' .$phpbbdir .$filename.'">'; echo "<br />"; echo "<br />"; echo "</font>"; echo "<br /><br />"; } ?> there must be a way to stop repeating all the same code for each function? many thanks This has probably been asked here tons of times, and yes I've searched on google but I can't find a decently explained method. What I want is to be able to upload a whole directory of pictures at once. These pictures must go through the following: Be cropped in size (about 600px width/height) This must be stored in a folder under a random name A thumbnail must be made, with the same name, in another folder The location of each picture should be stored in a database What I've said here is all PHP I presume, and that I can take care of, I think. The problem is the multiuploader. I understand it can't be done in PHP, since PHP lets only 1 file per input tag, so you cannot select a directory. So this should be done with javascript/java/??? Additional questions: if I do mkdir('/pictures/$mapname/thumbs');, the 'pictures' already exists but the rest doesn't. Does it create the $mapname dir and the thumbs, or should I use 2 different mkdir's? What width is best to save the images to? What with is the best to save the thumbs to? So many more, but I'll keep it at this! I know it's a lot of questions, but it would really be handy if I could do this! Thanks in advance! |