PHP - Php Mysql Video Uploading Problem
hi i m new to php
there is two basic script i m testing on my localhost but it gives me error "( ! ) Notice: Undefined index: video in C:\wamp\www\Boysjoys\video\upload.php on line 4" "( ! ) Notice: Undefined index: video in C:\wamp\www\Boysjoys\video\upload.php on line 16" "( ! ) Notice: Undefined index: video in C:\wamp\www\Boysjoys\video\upload.php on line 27" i cant find where is the real problem is ##########FORM########### <form name="upload" action="upload.php" method="POST" enctype="multipart/form-data"> <input type="file" name="video"> <input type="submit" value="UPLOAD"> </form> #########FORM############ #########PHP############# <?php // This is the directory where images will be saved $path="uploaded/"; $path=$path.basename($_FILES["video"]["name"]); //This gets all the other information from the form $video=$_FILES["video"]["name"]; //connect to database $con=mysql_connect("localhost","root","") or die (mysql_error()); //SELECTING THE DATABASE mysql_select_db("admin_bj",$con) or die(mysql_error()); //write information to the database mysql_query("INSERT INTO 'video'(video) VALUES('$video')"); //write file to server if(move_uploaded_file($_FILES["video"]["tmp_name"],$path)) { // execute if all is ok echo "the file " . basename( $_FILES['uploadedfile']['name']). "has been uploaded and your information has been added to the server"; } else { //GIVES AND ERROR IF ITS NOT OK echo "Sorry,there was a problem in uploading."; } ?> #########PHP############# Similar TutorialsHello,
How can I make gif from video while uploading it or after uploaded? Is there any tutorial.. I've been searched but didn't found anything.
The reason I want this is because when I upload video then I will show few thumbnails of the video on the page. Then when user hover the video will play short gif from the video 2-5 seconds and when the user click on video will play the video.. Hope you get what I mean.. I don't know how to explain it better. Just point me somewhere to read or watch about this..
Thank's in advanced!
p.s. Sorry for my English!
EDIT:
Here is the exaplme.. when you hover over the video an hold your mouse there it will play some gif
http://gifsoup.com/faq.php
Is it possible this?
Edited by vinsb, 10 September 2014 - 07:49 AM. Anyone know of a script that will allow you to upload a file and converts it to a specified file format? Folder layout: script/ script/videos/mp4/ } script/videos/ogg/ } folders for converted files from uploaded files script/videos/webm/ } script/videos/swf/ } Video player: Code: [Select] <video width="320" height="240" controls="controls"> <source src="script/videos/mp4/<? echo $movie; ?>.mp4" type="video/mp4" /> <source src="script/videos/ogg/ <? echo $movie; ?> .ogg" type="video/ogg" /> <source src="script/videos/webm/ <? echo $movie; ?> .webm" type="video/webm" /> <object data="script/videos/mp4/ <? echo $movie; ?> .mp4" width="320" height="240"> <embed src="script/videos/swf/ <? echo $movie; ?> .swf" width="320" height="240"> Your browser does not support video </embed> </object> </video> I have searched and searched the web for an answer and cannot find one pleas help? Hello
I want to know to upload the XML file to mysql using php as i am new to xml any help appreciated.
awaiting your valuable reply
here also i am attaching the xml file which i want to upload
Thanks in Advance
Attached Files
xml1.xml 4.89KB
2 downloads Does anyone know of a good tutorial on uploading a picture file to a folder using php and copying the name to the database in mysql? Resizing photos on upload is helpful also...If you know it works...some I have tried do not work. Not asking for someone to write code for me but info or tutorial would be nice. Or maybe a code that has worked for you that is similar that I could learn from and edit... I can upload the actual photo into the database but it slows it way down. I have heard of loading the name only and resizing the photo and sending the actual photo to a file folder on the server. The few codes I have tried were not successful. Thanks for any guidance. I appreciate it. Hi, I need some assistance with coding a form to upload a picture into MySQL DB. This will be part of a form and have a field where the user can upload a picture from where-ever, click submit and the image is uploaded into MySQL. If anyone has done this and can offer assistance with the html coding, PHP and how to set the field in MySQL, I would be greatly appreciative. what is the simple way to upload a photo to mysql or store in a dir, and update the database with the new url? Hi guys, I have this code that I created. It is suppost to get a file from a form and upload it to a directory that is outside the root folder of my webserver. then the image name is added to the preset location of the directory that contains all of the uploaded images and is placed into a mysql database so I can call it later. the problem I have is that when some one else signs up through this form and the file they upload has the same file name it replaces the one that is already in the images directory that has all the other pictures. I need to add something to this code that adds $username to the end of the original file name and then uploads it to the directory with the new name. Since every username is unique it will make every username unique and will eliminate my problem. I am not sure how to do this. Please, anyone that can help. Thanks. This is my code. // get file attributes!!!!! $photoname = $_FILES['photo']['name']; $tmp_name = $_FILES['photo']['tmp_name']; if ($photoname) { // start upload process $location = "../userpictures/$photoname"; move_uploaded_file($tmp_name,$location); } else { $location = "../userpictures/nophoto.png"; } $queryreg = mysql_query(" INSERT INTO users VALUES ('','$fullname','$username','$password','$date','$location','$email','$phone') "); If there is a better way to upload images to a mysql database and outputting it later then please let me know as well. Thanks. when i input this code it only uploads a single column into my database
<html> <head> <title>MySQL file upload example</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body> <form action="try2.php" method="post" enctype="multipart/form-data"> <input type="file" name="uploaded_file"><br> <input type="submit" name="submit"value="Upload file"> </form> <p> <a href="list_files.php">See all files</a> </p> </body> <?php $con=mysqli_connect("localhost","root","","book"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } if(isset($_POST['submit'])) { $fname = $_FILES['uploaded_file']['name']; $chk_ext = explode(".",$fname); if(strtolower($chk_ext[1]) == "csv") { $filename = $_FILES['uploaded_file']['tmp_name']; $handle = fopen($filename, "r"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $sql = "INSERT into data(name,Groups,phone_number) values('$data[0]','$data[1]','$data[2]')"; $result=mysqli_query($con,$sql) or die(mysql_error()); } fclose($handle); echo "Successfully Imported"; } else { echo "Invalid File"; } } ?> </html> hi everyone im new to php. I have been reading few books. im trying to build a image gallery. the first step is to upload a images. in the process of uploading, i want to resize the image then add watermark last insert into the database which is mysql, (i know about the dont insert image into database thing). here is the form script Code: [Select] <?php require_once('globals.php'); ?> <html> <head> <title>Upload an Image</title> </head> <body> <div> <h1>Upload an Image</h1> <p> <a href="./">View uploaded images</a> </p> <form method="post" action="process.php" enctype="multipart/form-data"> <div> <input type="file" name="image" /> <input type="submit" value="Upload Image" /> </div> </form> </div> <!-- <form action="watermark-image.php" method="post" enctype="multipart/form-data"> Select a file to upload for processing<br> <input type="file" name="File1"><br> <input type="submit" value="Submit File"> </form> --> </body> </html> here is the watermark script Code: [Select] <?php require_once('globals.php'); ?> <html> <head> <title>Upload an Image</title> </head> <body> <div> <h1>Upload an Image</h1> <p> <a href="./">View uploaded images</a> </p> <form method="post" action="process.php" enctype="multipart/form-data"> <div> <input type="file" name="image" /> <input type="submit" value="Upload Image" /> </div> </form> </div> <!-- <form action="watermark-image.php" method="post" enctype="multipart/form-data"> Select a file to upload for processing<br> <input type="file" name="File1"><br> <input type="submit" value="Submit File"> </form> --> </body> </html> here is my resize script Code: [Select] <?php # ========================================================================# # # Author: Jarrod Oberto # Version: 1.0 # Date: 17-Jan-10 # Purpose: Resizes and saves image # Requires : Requires PHP5, GD library. # Usage Example: # include("classes/resize_class.php"); # $resizeObj = new resize('images/cars/large/input.jpg'); # $resizeObj -> resizeImage(150, 100, 0); # $resizeObj -> saveImage('images/cars/large/output.jpg', 100); # # # ========================================================================# Class resize { // *** Class variables private $image; private $width; private $height; private $imageResized; function __construct($fileName) { // *** Open up the file $this->image = $this->openImage($fileName); // *** Get width and height $this->width = imagesx($this->image); $this->height = imagesy($this->image); } ## -------------------------------------------------------- private function openImage($file) { // *** Get extension $extension = strtolower(strrchr($file, '.')); switch($extension) { case '.jpg': case '.jpeg': $img = @imagecreatefromjpeg($file); break; case '.gif': $img = @imagecreatefromgif($file); break; case '.png': $img = @imagecreatefrompng($file); break; default: $img = false; break; } return $img; } ## -------------------------------------------------------- public function resizeImage($newWidth, $newHeight, $option="auto") { // *** Get optimal width and height - based on $option $optionArray = $this->getDimensions($newWidth, $newHeight, $option); $optimalWidth = $optionArray['optimalWidth']; $optimalHeight = $optionArray['optimalHeight']; // *** Resample - create image canvas of x, y size $this->imageResized = imagecreatetruecolor($optimalWidth, $optimalHeight); imagecopyresampled($this->imageResized, $this->image, 0, 0, 0, 0, $optimalWidth, $optimalHeight, $this->width, $this->height); // *** if option is 'crop', then crop too if ($option == 'crop') { $this->crop($optimalWidth, $optimalHeight, $newWidth, $newHeight); } } ## -------------------------------------------------------- private function getDimensions($newWidth, $newHeight, $option) { switch ($option) { case 'exact': $optimalWidth = $newWidth; $optimalHeight= $newHeight; break; case 'portrait': $optimalWidth = $this->getSizeByFixedHeight($newHeight); $optimalHeight= $newHeight; break; case 'landscape': $optimalWidth = $newWidth; $optimalHeight= $this->getSizeByFixedWidth($newWidth); break; case 'auto': $optionArray = $this->getSizeByAuto($newWidth, $newHeight); $optimalWidth = $optionArray['optimalWidth']; $optimalHeight = $optionArray['optimalHeight']; break; case 'crop': $optionArray = $this->getOptimalCrop($newWidth, $newHeight); $optimalWidth = $optionArray['optimalWidth']; $optimalHeight = $optionArray['optimalHeight']; break; } return array('optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight); } ## -------------------------------------------------------- private function getSizeByFixedHeight($newHeight) { $ratio = $this->width / $this->height; $newWidth = $newHeight * $ratio; return $newWidth; } private function getSizeByFixedWidth($newWidth) { $ratio = $this->height / $this->width; $newHeight = $newWidth * $ratio; return $newHeight; } private function getSizeByAuto($newWidth, $newHeight) { if ($this->height < $this->width) // *** Image to be resized is wider (landscape) { $optimalWidth = $newWidth; $optimalHeight= $this->getSizeByFixedWidth($newWidth); } elseif ($this->height > $this->width) // *** Image to be resized is taller (portrait) { $optimalWidth = $this->getSizeByFixedHeight($newHeight); $optimalHeight= $newHeight; } else // *** Image to be resizerd is a square { if ($newHeight < $newWidth) { $optimalWidth = $newWidth; $optimalHeight= $this->getSizeByFixedWidth($newWidth); } else if ($newHeight > $newWidth) { $optimalWidth = $this->getSizeByFixedHeight($newHeight); $optimalHeight= $newHeight; } else { // *** Sqaure being resized to a square $optimalWidth = $newWidth; $optimalHeight= $newHeight; } } return array('optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight); } ## -------------------------------------------------------- private function getOptimalCrop($newWidth, $newHeight) { $heightRatio = $this->height / $newHeight; $widthRatio = $this->width / $newWidth; if ($heightRatio < $widthRatio) { $optimalRatio = $heightRatio; } else { $optimalRatio = $widthRatio; } $optimalHeight = $this->height / $optimalRatio; $optimalWidth = $this->width / $optimalRatio; return array('optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight); } ## -------------------------------------------------------- private function crop($optimalWidth, $optimalHeight, $newWidth, $newHeight) { // *** Find center - this will be used for the crop $cropStartX = ( $optimalWidth / 2) - ( $newWidth /2 ); $cropStartY = ( $optimalHeight/ 2) - ( $newHeight/2 ); $crop = $this->imageResized; //imagedestroy($this->imageResized); // *** Now crop from center to exact requested size $this->imageResized = imagecreatetruecolor($newWidth , $newHeight); imagecopyresampled($this->imageResized, $crop , 0, 0, $cropStartX, $cropStartY, $newWidth, $newHeight , $newWidth, $newHeight); } ## -------------------------------------------------------- public function saveImage($savePath, $imageQuality="100") { // *** Get extension $extension = strrchr($savePath, '.'); $extension = strtolower($extension); switch($extension) { case '.jpg': case '.jpeg': if (imagetypes() & IMG_JPG) { imagejpeg($this->imageResized, $savePath, $imageQuality); } break; case '.gif': if (imagetypes() & IMG_GIF) { imagegif($this->imageResized, $savePath); } break; case '.png': // *** Scale quality from 0-100 to 0-9 $scaleQuality = round(($imageQuality/100) * 9); // *** Invert quality setting as 0 is best, not 9 $invertScaleQuality = 9 - $scaleQuality; if (imagetypes() & IMG_PNG) { imagepng($this->imageResized, $savePath, $invertScaleQuality); } break; // ... etc default: // *** No extension - No save. break; } imagedestroy($this->imageResized); } ## -------------------------------------------------------- } ?> here is the insert database script Code: [Select] <?php require_once('globals.php'); function assertValidUpload($code) { if ($code == UPLOAD_ERR_OK) { return; } switch ($code) { case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: $msg = 'Image is too large'; break; case UPLOAD_ERR_PARTIAL: $msg = 'Image was only partially uploaded'; break; case UPLOAD_ERR_NO_FILE: $msg = 'No image was uploaded'; break; case UPLOAD_ERR_NO_TMP_DIR: $msg = 'Upload folder not found'; break; case UPLOAD_ERR_CANT_WRITE: $msg = 'Unable to write uploaded file'; break; case UPLOAD_ERR_EXTENSION: $msg = 'Upload failed due to extension'; break; default: $msg = 'Unknown error'; } throw new Exception($msg); } $errors = array(); try { if (!array_key_exists('image', $_FILES)) { throw new Exception('Image not found in uploaded data'); } $image = $_FILES['image']; // ensure the file was successfully uploaded assertValidUpload($image['error']); if (!is_uploaded_file($image['tmp_name'])) { throw new Exception('File is not an uploaded file'); } $info = getImageSize($image['tmp_name']); if (!$info) { throw new Exception('File is not an image'); } } catch (Exception $ex) { $errors[] = $ex->getMessage(); } if (count($errors) == 0) { // no errors, so insert the image $query = sprintf( "insert into images (filename, mime_type, file_size, file_data) values ('%s', '%s', %d, '%s')", mysql_real_escape_string($image['name']), mysql_real_escape_string($info['mime']), $image['size'], mysql_real_escape_string( file_get_contents($image['tmp_name']) ) ); mysql_query($query, $db); $id = (int) mysql_insert_id($db); // finally, redirect the user to view the new image header('Location: view.php?id=' . $id); exit; } ?> <html> <head> <title>Error</title> </head> <body> <div> <p> The following errors occurred: </p> <ul> <?php foreach ($errors as $error) { ?> <li> <?php echo htmlSpecialChars($error) ?> </li> <?php } ?> </ul> <p> <a href="upload.php">Try again</a> </p> </div> </body> </html> here is my view script Code: [Select] <?php require_once('globals.php'); try { if (!isset($_GET['id'])) { throw new Exception('ID not specified'); } $id = (int) $_GET['id']; if ($id <= 0) { throw new Exception('Invalid ID specified'); } $query = sprintf('select * from images where image_id = %d', $id); $result = mysql_query($query, $db); if (mysql_num_rows($result) == 0) { throw new Exception('Image with specified ID not found'); } $image = mysql_fetch_array($result); } catch (Exception $ex) { header('HTTP/1.0 404 Not Found'); exit; } header('Content-type: ' . $image['mime_type']); header('Content-length: ' . $image['file_size']); echo $image['file_data']; ?> my main question is how to link them all together. any clues i appreciatte I am very new to php and am trying to create a simple application that uploads a PDF file to a database. I have one field for the Volume Number and on file field for the PDF to be uploaded. My issue is i can't get the PDF to upload or insert the name of the pdf (eg volume1.pdf) into the data base. I would also like to point out that I know i have a low post count, but i only seek help when i truly need it and have exhausted all other resources... Here is what i have, please go easy on me this is my first round at php: Code: [Select] <?php if(isset($_POST['submit'])){ $vol_num = $_POST['vol_num']; $pdf = $_FILES['pdf']['name']; $path = '../pdf/'.$_FILES['pdf']['name']; move_uploaded_file($_FILES["pdf"]["tmp_name"], $path); mysql_query("INSERT INTO volumes set vol_num='$vol_num', vol_link='$pdf'") or die (mysql_error()); echo "<script>location.href='add_volume.php'</script>"; } ?> what am i doing wrong here? Thanks in advance Greetings, What I'm trying to do is have users upload their event information into a database which would include a flyer. I don't want the image file to go into the database (other than the filename) rather I'd like it to be dropped into a directory. In the same script I'd like to dynamically generate a thumbnail. I have the two scripts and separately they work fine, but I can't get them to work together. I'm guessing the conflict because the thumbnail script is using $_POST and the mysql script is using $_SESSION. If so how can I modify them to both use $_SESSION? The thumbnail script is goes from line 1 - 146 and the mysql portion is the rest. The results of processing this look something like this. QUERY TEXT: INSERT INTO td_events (eventgenre_sel, eventname, eventvenue, eventdate, eventgenre, eventprice, eventpromoter, eventflyer) VALUES ('12', 'spooky times', 'Ironwood Stage & Grill', '2010-12-17 22:36:00', 'DNB', '5000', 'me', '174366-1.jpg') <?php $debug = FALSE; /********************************************************************************************** CREATES THUMBNAIL **********************************************************************************************/ //define a maxim size for the uploaded images define ("MAX_SIZE","1024"); // define the width and height for the thumbnail // note that theese dimmensions are considered the maximum dimmension and are not fixed, // because we have to keep the image ratio intact or it will be deformed define ("WIDTH","500"); define ("HEIGHT","650"); // this is the function that will create the thumbnail image from the uploaded image // the resize will be done considering the width and height defined, but without deforming the image function make_thumb($img_name,$filename,$new_w,$new_h) { //get image extension. $ext=getExtension($img_name); //creates the new image using the appropriate function from gd library if(!strcmp("jpg",$ext) || !strcmp("jpeg",$ext) || !strcmp("JPG",$ext)) $src_img=imagecreatefromjpeg($img_name); if(!strcmp("png",$ext) || !strcmp("PNG",$ext)) $src_img=imagecreatefrompng($img_name); //gets the dimmensions of the image $old_x=imageSX($src_img); $old_y=imageSY($src_img); // next we will calculate the new dimmensions for the thumbnail image // the next steps will be taken: // 1. calculate the ratio by dividing the old dimmensions with the new ones // 2. if the ratio for the width is higher, the width will remain the one define in WIDTH variable // and the height will be calculated so the image ratio will not change // 3. otherwise we will use the height ratio for the image // as a result, only one of the dimmensions will be from the fixed ones $ratio1=$old_x/$new_w; $ratio2=$old_y/$new_h; if($ratio1>$ratio2) { $thumb_w=$new_w; $thumb_h=$old_y/$ratio1; } else { $thumb_h=$new_h; $thumb_w=$old_x/$ratio2; } // we create a new image with the new dimmensions $dst_img=ImageCreateTrueColor($thumb_w,$thumb_h); // resize the big image to the new created one imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); // output the created image to the file. Now we will have the thumbnail into the file named by $filename if(!strcmp("png",$ext)) imagepng($dst_img,$filename); else imagejpeg($dst_img,$filename); //destroys source and destination images. imagedestroy($dst_img); imagedestroy($src_img); } // This function reads the extension of the file. // It is used to determine if the file is an image by checking the extension. function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } // This variable is used as a flag. The value is initialized with 0 (meaning no error found) // and it will be changed to 1 if an error occurs. If the error occurs the file will not be uploaded. $errors=0; // checks if the form has been submitted if(isset($_POST['Submit'])) { //reads the name of the file the user submitted for uploading $image=$_FILES['eventflyer']['name']; // if it is not empty if ($image) { // get the original name of the file from the clients machine $filename = stripslashes($_FILES['eventflyer']['name']); // get the extension of the file in a lower case format $extension = getExtension($filename); $extension = strtolower($extension); // if it is not a known extension, we will suppose it is an error, print an error message // and will not upload the file, otherwise we continue if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "JPG") && ($extension != "PNG") && ($extension != "png")) { echo '<h1>Unknown extension!</h1>'; $errors=1; } else { // get the size of the image in bytes // $_FILES[\'image\'][\'tmp_name\'] is the temporary filename of the file in which // the uploaded file was stored on the server $size=getimagesize($_FILES['eventflyer']['tmp_name']); $sizekb=filesize($_FILES['eventflyer']['tmp_name']); //compare the size with the maxim size we defined and print error if bigger if ($sizekb > MAX_SIZE*500) { echo '<h1>You have exceeded the size limit!</h1>'; $errors=1; } //we will give an unique name, for example the time in unix time format $image_name=$filename; //the new name will be containing the full path where will be stored (images folder) $newname="flyers/".$image_name; $copied = copy($_FILES['eventflyer']['tmp_name'], $newname); //we verify if the image has been uploaded, and print error instead if (!$copied) { echo '<h1>Copy unsuccessfull!</h1>'; $errors=1; } else { // the new thumbnail image will be placed in images/thumbs/ folder $thumb_name='flyers/thumb_'.$image_name; // call the function that will create the thumbnail. The function will get as parameters // the image name, the thumbnail name and the width and height desired for the thumbnail $thumb=make_thumb($newname,$thumb_name,WIDTH,HEIGHT); }} }} //If no errors registred, print the success message and show the thumbnail image created if(isset($_POST['Submit']) && !$errors) { echo "<h1>Thumbnail created Successfully!</h1>"; echo '<img src="'.$thumb_name.'">'; } /************************************************************ Adjust the headers... ************************************************************/ header("Expires: Thu, 17 May 2001 10:17:17 GMT"); // Date in the past header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header ("Pragma: no-cache"); // HTTP/1.0 /***************************************************************************** Check the session details. we will store all the post variables in session variables this will make it easier to work with the verification routines *****************************************************************************/ session_start(); if (!isset($_SESSION['SESSION'])) require_once( "../include/session_init.php"); $arVal = array(); require_once("../include/session_funcs1.php"); reset ($_POST); while (list ($key, $val) = each ($_POST)) { if ($val == "") $val = "NULL"; $arVals[$key] = (get_magic_quotes_gpc()) ? $val : addslashes($val); if ($val == "NULL") $_SESSION[$key] = NULL; else $_SESSION[$key] = $val; if ($debug) echo $key . " : " . $arVals[$key] . "<br>"; } /********************************************************************************************** Make sure session variables have been set and then check for required fields otherwise return to the registration form to fix the errors. **********************************************************************************************/ // check to see if these variables have been set... if ((!isset($_SESSION["eventname"])) || (!isset($_SESSION["eventvenue"])) || (!isset($_SESSION["eventdate"])) || (!isset($_SESSION["eventgenre"])) || (!isset($_SESSION["eventprice"])) || (!isset($_SESSION["eventpromoter"])) || (!isset($_SESSION["eventflyer"]))) { resendToForm("?flg=red"); } // form variables must have something in them... if ($_SESSION['eventname'] == "" || $_SESSION['eventvenue'] == "" || $_SESSION['eventdate'] == "" || $_SESSION['eventgenre'] == "" || $_SESSION['eventprice'] == "" || $_SESSION['eventpromoter'] == "" || $_SESSION['eventflyer'] == "") { resendToForm("?flg=red"); } /********************************************************************************************** Insert into the database... **********************************************************************************************/ $conn = mysql_connect($_SESSION['MYSQL_SERVER1'],$_SESSION['MYSQL_LOGIN1'],$_SESSION['MYSQL_PASS1']) or die ('Error connecting to mysql'); mysql_select_db($_SESSION['MYSQL_DB1']) or die("Unable to select database"); $eventgenre_sel = addslashes($_REQUEST['eventgenre_sel']); $eventname = addslashes($_REQUEST['eventname']); $eventvenue = addslashes($_REQUEST['eventvenue']); $eventdate = addslashes($_REQUEST['eventdate']); $eventgenre = addslashes($_REQUEST['eventgenre']); $eventprice = addslashes($_REQUEST['eventprice']); $eventpromoter = addslashes($_REQUEST['eventpromoter']); $eventflyer = addslashes($_REQUEST['eventflyer']); $sqlquery = "INSERT INTO td_events (eventgenre_sel, eventname, eventvenue, eventdate, eventgenre, eventprice, eventpromoter, eventflyer) " ."VALUES ('$eventgenre_sel', '$eventname', '$eventvenue', '$eventdate', '$eventgenre', '$eventprice', '$eventpromoter', '$eventflyer')"; echo 'QUERY TEXT:<br />'.$sqlquery; $result = MYSQL_QUERY($sqlquery); $insertid = mysql_insert_id(); /*** This following function will update session variables and resend to the form so the user can fix errors ***/ function resendToForm($flags) { reset ($_POST); // store variables in session... while (list ($key, $val) = each ($_POST)) { $_SESSION[$key] = $val; } // go back to the form... //echo $flags; header("Location: /user_registration.php".$flags); exit; } mysql_close($conn); ?> hi guys... I'm resizing image with some script. it works fine. but some times it gives following error and make image black. either it should not upload/resize image or it should do that for all. following is the error list i found on some images Code: [Select] Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg: JPEG library reports unrecoverable error: in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 49 Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: '../../../directory/images/large/0419063.jpg' is not a valid JPEG file in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 49 Warning: imagesx() expects parameter 1 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 34 Warning: imagesy() expects parameter 1 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 35 Warning: Division by zero in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 182 Warning: Division by zero in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 183 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 76 Warning: imagecopyresampled() expects parameter 1 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 77 Warning: imagecopyresampled() expects parameter 2 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 201 Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg: JPEG library reports unrecoverable error: in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 49 Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: '../../../directory/images/thumb/0419063.jpg' is not a valid JPEG file in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 49 Warning: imagesx() expects parameter 1 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 34 Warning: imagesy() expects parameter 1 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 35 Warning: Division by zero in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 182 Warning: Division by zero in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 183 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 76 Warning: imagecopyresampled() expects parameter 1 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 77 Warning: imagecopyresampled() expects parameter 2 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 201 Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg: JPEG library reports unrecoverable error: in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 49 Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: '../../../directory/images/medium/0419063.jpg' is not a valid JPEG file in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 49 Warning: imagesx() expects parameter 1 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 34 Warning: imagesy() expects parameter 1 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 35 Warning: Division by zero in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 182 Warning: Division by zero in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 183 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 76 Warning: imagecopyresampled() expects parameter 1 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 77 Warning: imagecopyresampled() expects parameter 2 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 201 Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg: JPEG library reports unrecoverable error: in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 49 Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: '../../../directory/images/xlarge/0419063.jpg' is not a valid JPEG file in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 49 Warning: imagesx() expects parameter 1 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 34 Warning: imagesy() expects parameter 1 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 35 Warning: Division by zero in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 182 Warning: Division by zero in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 183 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 76 Warning: imagecopyresampled() expects parameter 1 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 77 Warning: imagecopyresampled() expects parameter 2 to be resource, boolean given in C:\Program Files\VertrigoServ\www\demo\administrator\modules\directory\classes\resize-class.php on line 201 This is my PHP code which uploads the image from a html form. <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Upload a Photograph</title> <link rel="stylesheet" href="uploadify.css" type="text/css" /> <script language="JavaScript" type="text/javascript"> <!-- function breakout_of_frame() { // see http://www.thesitewizard.com/archive/framebreak.shtml // for an explanation of this script and how to use it on your // own website if (top.location != location) { top.location.href = "http:/noltest.lib.siu.edu/drupal/blincore?file='"+fileObj.name+"'" ; } } --> </script> <script type="text/javascript" src="jquery-1.3.2.min.js"></script> <script type="text/javascript" src="jquery.uploadify.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#fileUpload").fileUpload({ 'uploader': 'uploader.swf', 'cancelImg': 'cancel.png', 'script': 'upload.php', 'folder': 'downloads', 'fileDesc': 'Image Files', 'fileExt': '*.jpeg,*.jpg,*.tif,*.tiff,*.gif,*.png', 'checkScript': 'check.php', 'multi': false, 'displayData': 'speed', 'onComplete': function(event, queueID, fileObj, response, data) { $('#filesUploaded').append ('One Image Uploaded successfully (<a href='+fileObj.filePath+'>'+fileObj.name+'</a>)</br></br> <FORM METHOD=POST ACTION="http://nol.lib.siu.edu/drupal/dublincore"> <INPUT NAME=filename value="'+fileObj.name+'"> <INPUT TYPE=submit VALUE="NEXT" ></FORM ><br>');} }); }); </script> </head> <body style="background: #f1ede0 url(http://nol.lib.siu.edu//sites/all/themes/admire_grunge/images/bg2.jpg) repeat fixed top center;"> <h2>Single Photograph Upload</h2> <div id="fileUpload">Issue with your javascript</div> <a href="javascript:$('#fileUpload').fileUploadStart()">Start Upload</a> | <a href="javascript:$('#fileUpload').fileUploadClearQueue()">Clear Queue</a> <p></p> <p><div id="filesUploaded"></div></p> </body> </html> problem: when i try to upload image from the desktop which contains image named (test.jpg) , this test.jpg is not shown when browsing to select the image file. any advice... I am having trouble getting my upload file to work... Form HTML: Code: [Select] <form action="" method="POST"> <input type="file" name="file" /> <input type='"submit" name="upload" value="Upload" /> </form> PHP: Code: [Select] if($_POST["upload_avatar"]){ $upload_path = "images/users/"; $file = $_FILES["file"]["name"]; $extension_types = array("gif","jpg","jpeg","png"); if($file){ $filename = stripslashes($_FILES["file"]["name"]); $extension = getExtension($filename); $extension = strtolower($extension); $size = filesize($_FILES["file"]["tmp_name"]); if(in_array($extension, $extension_types)){ if($size <= $max_file_size){ $file_search = glob($upload_path . strtolower($username) . '*'); array_map("unlink", $file_search); $file_name = $upload_path . strtolower($username) . "." . $extension; $copied = copy($_FILES["file"]["tmp_name"], $file_name); if (!$copied){ $r_error = "Upload has failed"; } } else{$r_error = "File too big";} } else{$r_error = "Unknown file extension";} } else{$r_error = "No file chosen";} } Every time, it gives me the "No File Chosen" error. It doesn't seem to be actually uploading the file... I hope this isn't just some stupid thing I am looking over, can someone help me? Hi, I have a strange problem with uploading files. My script was working fine on the test server but since moving to the live server it isn't working. Here is a printout of the FILES variable: Code: [Select] Array ( [file] => Array ( [name] => filename.ppt [type] => [tmp_name] => [error] => 1 [size] => 0 ) ) Does anyone know what the problem might be? The error message that comes back is 'Invalid file'. Code: [Select] function upload_ppt_files() { echo 'print_r($_FILES) = '.print_r($_FILES).'<br />'; global $CFG; if (($_FILES["file"]["type"] == "application/vnd.ms-powerpoint") && ($_FILES["file"]["size"] > 100)) { if ($_FILES["file"]["error"] > 0) { $CFG->message = "Error code:". $_FILES["file"]["error"]; manage_ppt_files(); } else { if (file_exists("../../uploads/" . $_FILES["file"]["name"])) { $CFG->message = $_FILES["file"]["name"] . " already exists."; manage_ppt_files(); } else { move_uploaded_file($_FILES["file"]["tmp_name"], "../../uploads/" . $_FILES["file"]["name"]); $CFG->message = "File uploaded successfully."; manage_ppt_files(); } } } else { $CFG->message = "Invalid File."; manage_ppt_files(); } } I have a php website with two parts the client part and an admin part in the client part or the viewers end , i need to show the details of products with description and an image (in the front page). The details are entered though the admin part. My problem is the image uploaded goes to the folder in the admin folder but in the home page the images are taken from the images folder suitated in outside the admin folder . How can i upload images or photos to the folder outside the admin though the admin pages. Pasting my code here Code: [Select] $target = "pics/"; [color=red]//this is created in the admin folder, i need to change here that is keep the folder outside the admin folde[/color]r $target = $target . basename( $_FILES['photo']['name']); $pic=($_FILES['photo']['name']); $image=$pic; $box_num =$_POST['box_num']; $query11 = "update photo_table set page_head='$page_head',image='$image' where id='$box_num'"; $result11 = mysql_query($query11); if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; } }else { echo "Sorry, there was a problem uploading your file."; } } } I'm working on a portal project for a school and they make weekly flyers like the one attached below. Now if the file attaches to this post, then at least I know some script changes will fix the problem. The school has an archive of hundreds of these docs they'd like to load up, so I need a solution. I've made many versions of my upload script, which have been working fine for any word documents I create, but not for their word docs. This is the code in my latest version. Code: [Select] <?php require("checkpass2.php"); require("../teacher/checkpass.php"); require("../access.inc.php"); mysql_connect("$host","$login","$pass") OR DIE ("There is a problem with the system. Please notify your system administrator." .mysql_error()); mysql_select_db("$db") OR DIE ("There is a problem with the system. Please notify your system administrator." .mysql_error()); include("../commonsettings.php"); IF ($_POST['upload']){ //$directory="$siteurl"; $directory=".."; $section=$_POST['section']; $directoryname = preg_replace('/[^a-zA-Z]/', '', $section); $directlevel="$directory/$directoryname"; if(!file_exists($directlevel, 0777)) { mkdir($directlevel); } $target_path = "$directlevel/"; $loaddate = date('MY'); $filename = preg_replace('/\s+/', '', $_FILES['uploadedfile']['name']); $file_basename = substr($filename, 0, strripos($filename, '.')); // strip extention $file_ext = substr($filename, strripos($filename, '.')); // strip name $filesize = $_FILES["uploadedfile"]["size"]; if (($file_ext == ".doc" || $file_ext == ".docx") && ($filesize < 200000)) { // rename file $newfilename = $file_basename."_Uploaded_".date('M-Y') . $file_ext; $nfilename = $newfilename; if (file_exists($target_path . $newfilename)) { unlink($target_path . $newfilename); mysql_query("DELETE FROM ".$conf['tbl']['uploads']." WHERE filename='$nfilename' AND section='$directoryname'") or die(mysql_error()); } if (!file_exists($target_path . $newfilename)) { move_uploaded_file($_FILES["uploadedfile"]["tmp_name"], $target_path . $newfilename); $result = mysql_query("INSERT INTO ".$conf['tbl']['uploads']." SET filename='$nfilename', section='$directoryname'") or die(mysql_error()); header("Location:UploadFiles.php"); } } elseif (empty($file_basename)) { // file type error header("Location:UploadFiles.php?error=1"); } else { // file selection error header("Location:UploadFiles.php?error=2"); } } ?>Any help greatly appreciated. [attachment deleted by admin] Hi All, I have been having issues for several days uploading a simple pdf file via Curl to one of our service providers servers. I'm doing an is_uploaded_file check and getting a successful response, but the document is not actually being uploaded to the server. Can anyone help?? Please see code below: Code: [Select] $filename = $_FILES['activity_doc']['name']; // Name of the file (including file extension). $upload_path = https://upload_url //Curl session initialized $session = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)"); curl_setopt($session, CURLOPT_URL, $upload_path); curl_setopt($session, CURLOPT_USERPWD, 'username:password'); curl_setopt($session, CURLOPT_POST, 1); $post = array( "file_box"=>"@" . $filename, ); curl_setopt($session, CURLOPT_POSTFIELDS, $post); $response = curl_exec($session); if (is_uploaded_file($_FILES['activity_doc']['tmp_name'])) { echo "File ". $_FILES['activity_doc']['name'] ." uploaded successfully.\n"; } else { echo "Error occurred, file uploaded unsuccessful"; } $req = new SimpleXMLElement($response); print_r($req); curl_close($session); |