PHP - How To Convert Vertabelo Xml File To Propel's Schema.xml File
If you are using Vertabelo for creating database models and you access your database with Propel library, you'll find the following instructions useful.
Similar TutorialsHello, all: been trying to convert this little single-file upload to multiple by naming each file form-field as "userfile[]" as it's supposed to automatically treat them as an array.. but no luck! Can you guide me as to what am I doing wrong?? appreciate the help! Code: [Select] <?php if (!isset($_REQUEST["seenform"])) { ?> <form enctype="multipart/form-data" action="#" method="post"> Upload file: <input name="userfile[]" type="file" id="userfile[]"> Upload file: <input name="userfile[]" type="file" id="userfile[]"> <input type="submit" value="Upload"> <input type="hidden" name="seenform"> </form> <?php } else { // upload begins $userfiles = array($_FILES['userfile']); foreach ($userfiles as $userfile) { // foreach begins $uploaded_dir = "uploads/"; $userfile = $_FILES['userfile']["name"]; $path = $uploaded_dir . $userfile; if (move_uploaded_file($_FILES['userfile']["tmp_name"], $path)) { print "$userfile file moved"; // do something with the file here } else { print "Move failed"; } } // foreach ends } // upload ends ?> Hello Friends, I need to convert the DOC (WordFile) in to PDF through PHP code in my web. According to requirement whenever the user upload the .Doc file code should convert that .Doc file into .PDF file at runtime. I have tried by using PDFLib and FPDF functions but when the .Doc file contains the images,tables etc. either FPDF or PdfLib being falied to generate PDF file I am using Linux-PHP-MySQL Technolgoies for development. I am expecting suggestions and help from expert friends who can help me out to achive this. Thanks! I am having a rtf file, now i want to convert that rtf file to html version with same alignment, to be display in the web page. Kindly give some example in php. I want to convert a webpage from my system using PHP into a PDF file. Just how http://www.web2pdfconvert.com/ works. However, I want to have a link that says 'Convert to PDF' then it automatically converts the webpage into a PDF. Is there any way to do this? Magandang Araw, Just want to ask if this idea is feasible or something, these past few days im doing some research on how materialize the said topic and apparently there were no sound solution so far. , im working on a script that allows users to publish html design to jpg, Im done with Imagemagik since its the nearest inline with the specs, so is there any other solution aside from this? im thinking of a php script that will do the job, more likely some gdlibrary manipulation or something. Salamat Jestoni I am trying to convert 6 files into a single 1 php file. I have attached the original files. I need help because I don't know where I am going wrong. this what I have done so far : <?php session_start(); if ($_SESSION['ON'] =="FALSE" || $_SESSION['ON']==null) { header( 'Location: index.php?error=invalid-login' ); session_unset(); session_destroy(); exit(); } ?> <html><head><meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>LOGIN WEB SESSION</title> <link rel="stylesheet" type="text/css" href="loginsession.css" /> </head> <body> <?php // If the step is one, show the correct form // if ($step == 0) { echo '<form action="index.php?step=2" method="post"> <table> <tr><td width="100">Username:</td><td width="200"><input type="text" name="username"></td></tr> <tr><td width="100">Password:</td><td width="200"><input type="password" name="password"></td></tr> <tr><td colspan="2" align="center"><input type="submit" value="Login"></td></tr> </table> </form>'; } else if ($step == 1) { // Create the step 2 section of the page // function clean($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } $user = clean($_POST['username']); $pass = clean($_POST['password']); if ($user == "webdeveloper" && $pass == "master") { session_start(); $_SESSION['username'] = $user; $_SESSION['password'] = $pass; $_SESSION['ON']="TRUE"; $lifetime=600; setcookie(session_name(),session_id(),time()+$lifetime); header( 'Location: index.php?step=2' ) ; exit(); } else { header( 'Location: index.php' ); session_destroy(); exit(); } } else if ($step == 2) <div>LOGIN WELCOME</div> <div> HERE IS YOUR USER DATA:<br /> <label class="data">username:'; <?php echo $_SESSION['username'] ?> <br> password: <?php echo $_SESSION['password'] ?> <br></label> HERE IS YOUR SESSION DATA:<br /> <label class="data"> <?php echo (session_name().": ".session_id()) ?><br> <?php echo ("SESSION DATA: ".session_encode() )?> </label> </div>index.php?step=3">Logoff</a></div> } else if ($step == 3) { // Create the step 4 section of the page // header( 'Location: index.php' ); session_start(); session_unset(); session_destroy(); exit(); } ?> </body> </html> I need to convert the following table and graph to PDF when button is clicked. Please help I am using fusion charts and generated graph will be swf file // Table and graph for all students if(isset($_POST['ReportAll'])){ $strQuery = ("SELECT registration_number,SUM(Fine) AS Total_Fine FROM lended_book_cd GROUP BY registration_number"); $result=mysql_query($strQuery); if (!$result){ Error (mysql_error()) ; } if (mysql_num_rows($result)!==0){ $table=1; echo $input_table; echo "<center>Fine report for All Students </center>"; echo "<br>"; echo "<table border='2' align='center'>"; echo("<tr>"); for($i=0;$i<mysql_num_fields($result);$i++){ echo("<th>".mysql_field_name($result,$i)."</th>"); } while($data=mysql_fetch_array($result)){ echo("<tr>"); for($i=0;$i<mysql_num_fields($result);$i++){ echo("<td>".$data[$i]."</td>"); } } echo "</table>"; } else{ Info ("No Fine Reports found for Student $_POST[regnum]"); } $strQuery = ("SELECT registration_number,SUM(Fine) AS Total_Fine FROM lended_book_cd GROUP BY registration_number"); //Where lended_book_cd.registration_number = students.registration_number $result=mysql_query($strQuery); $strXML = "<graph caption='Fine report for All Students' showLabels='1' xAxisName='Student Registration Number' yAxisName='Fine Value' showNames='1' showValues='1' useRoundEdges='1' palette='3'>"; while($ors = mysql_fetch_array($result)) { // Append the names of the countries and their respective populations to the chart's XML string. $strXML .= "<set name='$ors[registration_number]' value='$ors[Total_Fine]' />"; } $strXML .= "</graph>"; echo renderChart('charts/FCF_Column2D.swf', // Path to chart type '', // Empty string when using Data String Method $strXML, // Variable that contains XML string 'chart1Id', // Unique chart ID '560', '400', // Width and height in pixels false, // Disable debug mode true // Enable 'Register with JavaScript' (Recommended) ); } Hello, I am novice in PHP, I read book and try to write some PHP code, but I don't have success in that my attempt. Do someone can to help me? I think that this what I work isn't hard, but I don't know to do. I need to create in PHP some code which will: 1. In text field I enter some words in 2-3 rows, example word11 word12 word13 word21 word22 word23 word31 word32 word33 and click to button Convert, 2. After click on that button php script will take that words and convert into this mode: word11-word12-word13(TAB here without space)word11 word12 word23 word21-word22-word23(TAB here without space)word21 word22 word23 word31-word32-word33(TAB here without space)word31 word32 word33 (spaces between words will convert into - and between first and second mode with TAB) 3. On that way converted text to be saved into new file which will be with name of first line "word11 word12 word13". I know procedure to make this, but I don't know syntax very well Can someone write me code or part of code, to give me idea how I to make this? Thank you very much, Mladen Hey, been trying to make a form to upload an image to the server and also email the image as attachment. After nearly a week I managed to make it work. Only some validation needs to be done. My next step is to make it work for multiple files, ie. 5. The form will have 5 boxes to upload images and no more. I have tried a few different things with for loops ( ie for $i=0; $i<5; $i++ {...} ) but no luck. I can't think of any solution of a loop to upload multiple files and then email multiple attachment as my code. The code is: <?php session_start(); $imagename1 = $_FILES["uploadFile1"]["name"]; $_SESSION['imagename1'] = $imagename1; $imagename1 = $_SESSION['imagename1']; $imagetype1 = $_SESSION['imagetype1']; $imagesize1 = $_SESSION['imagesize1']; $imagetemp1 = $_SESSION['imagetemp1']; $thankyouurl = 'thankyou.php' ; $errorurl = 'error.php' ; $http_referrer = getenv( "HTTP_REFERER" ); $http_agent = getenv( "HTTP_USER_AGENT" ); $domain = $_SERVER['REMOTE_ADDR']; $filename = $_SESSION['uploadFilename']; if(isset($_POST['send'])) { $fp = fopen($imagetemp1, "rb"); $file = fread($fp, $imagesize1); $file = chunk_split(base64_encode($file)); $num = md5(time()); fclose($fp); // UPLOAD FILE // possible PHP upload errors $errors = array(1 => 'php.ini max file size exceeded', 2 => 'html form max file size exceeded', 3 => 'file upload was only partial', 4 => 'no file was attached'); // check the upload form was actually submitted else print form isset($_POST['send']) or error('the upload form is neaded', $uploadForm); // check for standard uploading errors ($_FILES[$fieldname1]['error'] == 0) or error($errors[$_FILES[$fieldname1]['error']], $uploadForm); // check that the file we are working on really was an HTTP upload @is_uploaded_file($_FILES[$fieldname1]['tmp_name']) or error('not an HTTP upload', $uploadForm); // validation... since this is an image upload script we // should run a check to make sure the upload is an image @getimagesize($_FILES[$fieldname1]['tmp_name']) or error('only image uploads are allowed', $uploadForm); // make a unique filename for the uploaded file and check it is // not taken... if it is keep trying until we find a vacant one $now = date("y-m-d_H-i-s", time()); while(file_exists($uploadFilename = $uploadsDirectory.$now.'_'.$_FILES[$fieldname1]['name'])) { $now++; } // now let's move the file to its final and allocate it with the new filename @move_uploaded_file($_FILES[$fieldname1]['tmp_name'] , $uploadFilename) or error('receiving directory insuffiecient permission', $uploadForm); $from= 'youremail@server.co.uk'; $emailTo = 'mail@hotmail.com'; $subject = 'Quote Form'; $body = "equipment_type: $equipment_type \n\nModel: $Model \n\nMake: $Make \n\nModelNumber: $ModelNumber"; $fp = $_SESSION['fp']; $file = $_SESSION['file']; $num = "==Multipart_Boundary_x{$semi_rand}x".$_SESSION['num']; $headers = 'From: Name <'.$from.'>' . "\r\n" . 'Reply-To: ' . $emailTo; //Normal headers $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: multipart/mixed; "; $headers .= "boundary=".$num."\r\n"; $headers .= "--$num\r\n"; // This two steps to help avoid spam $headers .= "Message-ID: <".gettimeofday()." TheSystem@".$_SERVER['SERVER_NAME'].">\r\n"; $headers .= "X-Mailer: PHP v".phpversion()."\r\n"; // With message $headers .= "Content-Type: text/html; charset=iso-8859-1\r\n"; $headers .= "Content-Transfer-Encoding: 8bit\r\n"; $headers .= "".$body."\n"; $headers .= "--".$num."\n"; // Attachment headers $headers .= "Content-Type:".$imagetype1." "; $headers .= "name=\"".$imagename1."\"r\n"; $headers .= "Content-Transfer-Encoding: base64\r\n"; $headers .= "Content-Disposition: attachment; "; $headers .= "filename=\"".$imagename1."\"\r\n\n"; $headers .= "".$file."\r\n"; $headers .= "--".$num."--"; mail($emailTo, $subject, $body, $headers); header( "Location: $thankyouurl" ); } ?> the form is like this Code: [Select] <input name="uploadFile1" id="uploadFile1" value="" class="file" type="file"/>can anyone suggest anything please? how can I form the for statement? much appreciated how to get the name of the file including a file from the included file, This one has me mixed up a bit.. I am trying to record site activity information from a common.php file using a user object. But since the file is included into different php files based on different situations I need a dynamic way of finding the file name that is including it. I could be over complicating things but right now this seems like the best solution other wise I'll have to rewrite the code on every page i write. Is there a function for doing this? Or if someone gets what I'm trying to do if they could point me to the direction of some more information on it. Thanks. Hiya, Firstly, I'm a complete novice, apologies! But I have got my upload.php working which is nice. I will post the code below. However, I would now like to restrict the file size and file type to only word documents. I currently have a restriction of 200KB but it's not working - no idea why as I've looked at other similar codes and they look the same. Also, just to complicate things - can I stop files overwriting each other when uploaded? At the moment, if 2 people upload files with the same name one will overwrite the other. Is this too many questions in 1? Any help is very much appreciated! Code below: Code: [Select] <form enctype="multipart/form-data" action="careers.php" method="POST"> Please choose a file: <input name="uploaded" type="file" /><br /> <input type="submit" value="Upload" /> </form> <?php $target = "upload/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; //This is our size condition if ($uploaded_size > 200) { echo "Your file is too large.<br>"; $ok=0; } //This is our limit file type condition if ($uploaded_type =="text/php") { echo "No PHP files<br>"; $ok=0; } //Here we check that $ok was not set to 0 by an error if ($ok==0) { Echo "Sorry your file was not uploaded"; } //If everything is ok we try to upload it else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "Your file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded."; } else { echo "Sorry, there was a problem uploading your file."; } } ?> I'm using an Upload Script, and I've been working on trying to style the 'Choose File Button' (input file button) In this multi file upload form, choose three images, click submit and preview the images on the preview page. If the user wishes to delete or replace an image, click edit and the form will go back to the previous page. Select the replace radio button for example on one of the three images and select a new image from the file input prompt and click submit. The form will go to the preview page again to display the images. During this process the image names are being input into a table and the images are being moved to a directory. The table is `id` AUTO_INCREMENT, `image0` `image1` `image2` `status` So input name='image[image0]' can be directed to table `image0` and so on. The code for keep and delete work fine, but how do I replace an image? I have two foreach blocks. The first one deletes the image file from the directory and deletes the image name from the table, but the second foreach dose not move the new image file into the directory. Thanks. <input type='radio' name='image[image0]' value='keep' checked='checked'/> <input type='radio' name='image[image0]' value='delete' /> <input type='radio' name='image[image0]' value='replace' /> <input type="file" name="image[]" /> <input type='radio' name='image[image1]' value='keep' checked='checked'/> <input type='radio' name='image[image1]' value='delete' /> <input type='radio' name='image[image1]' value='replace' /> <input type="file" name="image[]" /> <input type='radio' name='image[image2]' value='keep' checked='checked'/> <input type='radio' name='image[image2]' value='delete' /> <input type='radio' name='image[image2]' value='replace' /> <input type="file" name="image[]" /> <?php if (isset($_POST['status'])) { $status = $_POST['status']; $confirm_code = $status; #--------------------------- replace -------------------------------------------- if (isset($_POST['submitted']) && ($image = $_POST['image'])) { foreach($image as $imageKey => $imageValue) { if ($imageValue == 'replace') { $query = "SELECT $imageKey FROM table WHERE status = '$status' "; if($result = $db->query( $query )){ $row = $result->fetch_array(); } unlink( UPLOAD_DIR.$row[0] ); $query = "UPDATE table SET $imageKey = '' WHERE status = '$status' "; } } foreach($image as $imageKey => $imageValue) { if ($imageValue == 'replace') { $filenm = $_FILES['image']['name']; $file = $_FILES['image']['tmp_name']; move_uploaded_file($file, UPLOAD_DIR . $filenm); $filename[] = $filenm; $query = "INSERT INTO table VALUES ('','$filename[0]','$filename[1]','$filename[2]','$confirm_code')"; } } } } ?> Hey everyone, I'm pretty new to this, not my full time job, but just something I thought I'd give a shot... I have a database, in postgres, in which I make my query and I go fetch all the info I need. What I need to do next is the tricky part for me. For each line of results received, I have to output to a text file (.txt) but I have to respect a format that was given to me from the person requesting the info. Example: Character 1 must be G or N. Character 2 to to 11 will be a result from my database search, which is a 10 digit string. Character 12 to 14 must be spaces. Another rule is: start at character 78: input a value from my database search but it must not exceed 20 characters and if it is less then 20 character, fill the remaining with spaces. If anyways has a code I can copy and work off of I would really appreciate it....thanks! I have a page using forms to help build listing templates for eBay. I have a folder where I have hundreds of logos stored. I know the logo names but not their extensions. . . . I have to test each potential (jpg, jpeg, gif, png, etc.) until I guess right. Here is an example code for the web form:
<form action="extension_test2.php" method="post"> <p>Logo: <input name="e" value="" type="text" size="15" maxlength="30" /><p> <input name="Submit" type="Submit"/> </form> and the form's result: <? $e =$_POST['e']; if(!empty($e)) { echo '<img src="http://www.gbamedica...ebayimg/logos/'.$e.'">'; }; ?> Here is a link to the example: http://www.gbamedica...ension_test.php Use "olympus.jpg" for test. I am looking for code that can determine the file type and dynamically add the extension. Can it be done? I am using apache web server on linux. I am using PHP for web designing. On web server, i want to show the configuration data by reading the ini file. I am creating this ini file from one php code itself. If this php code i run through linux terminal, the file is created with file and group owner as root.(i am having sudo rights on machine) Then if i try to read the ini file from my apache web server, it gives warning as failed to open stream: permission denied. I have tried changing the owner, and permissions to 777 of the file. Still it is not readable.
On the other hand, if i run the php code of ini file creation through web server, ini file is created with file and group owner as apche. and web server is able to read/ write the file.
But i want to create that file from root or some other user and later read/written by apache.
How to give this access permission?
So, I'm learning how to upload pictures into a system from my awesome PHP book. I've looked and looked through the script but I can't figure out whats wrong with it. Goal: The script is meant to save a full version of the image in the images folder and a thumbnail in the thumbnail folder. Bug: The full image does not appear in any folder, and the thumbnail is created but its put in the images folder. I've checked the GD library, and everything is supported. image_effect.php <?php //change this path to match your images directory $dir ='C:/x/xampp/htdocs/images'; //change this path to match your fonts directory and the desired font putenv('GDFONTPATH=' . 'C:/Windows/Fonts'); $font = 'arial'; // make sure the requested image is valid if (isset($_GET['id']) && ctype_digit($_GET['id']) && file_exists($dir . '/' . $_GET['id'] . '.jpg')) { $image = imagecreatefromjpeg($dir . '/' . $_GET['id'] . '.jpg'); } else { die('invalid image specified'); } // apply the filter $effect = (isset($_GET['e'])) ? $_GET['e'] : -1; switch ($effect) { case IMG_FILTER_NEGATE: imagefilter($image, IMG_FILTER_NEGATE); break; case IMG_FILTER_GRAYSCALE: imagefilter($image, IMG_FILTER_GRAYSCALE); break; case IMG_FILTER_EMBOSS: imagefilter($image, IMG_FILTER_EMBOSS); break; case IMG_FILTER_GAUSSIAN_BLUR: imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR); break; } // add the caption if requested if (isset($_GET['capt'])) { imagettftext($image, 12, 0, 20, 20, 0, $font, $_GET['capt']); } //add the logo watermark if requested if (isset($_GET['logo'])) { // determine x and y position to center watermark list($width, $height) = getimagesize($dir . '/' . $_GET['id'] . '.jpg'); list($wmk_width, $wmk_height) = getimagesize('images/logo.png'); $x = ($width - $wmk_width) / 2; $y = ($height - $wmk_height) / 2; $wmk = imagecreatefrompng('images/logo.png'); imagecopymerge($image, $wmk, $x, $y, 0, 0, $wmk_width, $wmk_height, 20); imagedestroy($wmk); } // show the image header('Content-Type: image/jpeg'); imagejpeg($image, '', 100); ?> check_image.php <?php include 'db.inc.php'; //connect to MySQL $db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD) or die ('Unable to connect. Check your connection parameters.'); mysql_select_db(MYSQL_DB, $db) or die(mysql_error($db)); //change this path to match your images directory $dir ='C:/x/xampp/htdocs/images'; //change this path to match your thumbnail directory $thumbdir = $dir . '/thumbs'; //change this path to match your fonts directory and the desired font putenv('GDFONTPATH=' . 'C:/Windows/Fonts'); $font = 'arial'; // handle the uploaded image if ($_POST['submit'] == 'Upload') { //make sure the uploaded file transfer was successful if ($_FILES['uploadfile']['error'] != UPLOAD_ERR_OK) { switch ($_FILES['uploadfile']['error']) { case UPLOAD_ERR_INI_SIZE: die('The uploaded file exceeds the upload_max_filesize directive ' . 'in php.ini.'); break; case UPLOAD_ERR_FORM_SIZE: die('The uploaded file exceeds the MAX_FILE_SIZE directive that ' . 'was specified in the HTML form.'); break; case UPLOAD_ERR_PARTIAL: die('The uploaded file was only partially uploaded.'); break; case UPLOAD_ERR_NO_FILE: die('No file was uploaded.'); break; case UPLOAD_ERR_NO_TMP_DIR: die('The server is missing a temporary folder.'); break; case UPLOAD_ERR_CANT_WRITE: die('The server failed to write the uploaded file to disk.'); break; case UPLOAD_ERR_EXTENSION: die('File upload stopped by extension.'); break; } } //get info about the image being uploaded $image_caption = $_POST['caption']; $image_username = $_POST['username']; $image_date = @date('Y-m-d'); list($width, $height, $type, $attr) = getimagesize($_FILES['uploadfile']['tmp_name']); // make sure the uploaded file is really a supported image $error = 'The file you uploaded was not a supported filetype.'; switch ($type) { case IMAGETYPE_GIF: $image = imagecreatefromgif($_FILES['uploadfile']['tmp_name']) or die($error); break; case IMAGETYPE_JPEG: $image = imagecreatefromjpeg($_FILES['uploadfile']['tmp_name']) or die($error); break; case IMAGETYPE_PNG: $image = imagecreatefrompng($_FILES['uploadfile']['tmp_name']) or die($error); break; default: die($error); } //insert information into image table $query = 'INSERT INTO images (image_caption, image_username, image_date) VALUES ("' . $image_caption . '", "' . $image_username . '", "' . $image_date . '")'; $result = mysql_query($query, $db) or die (mysql_error($db)); //retrieve the image_id that MySQL generated automatically when we inserted //the new record $last_id = mysql_insert_id(); // save the image to its final destination $image_id = $last_id; imagejpeg($image, $dir . '/' . $image_id . '.jpg'); imagedestroy($image); } else { // retrieve image information $query = 'SELECT image_id, image_caption, image_username, image_date FROM images WHERE image_id = ' . $_POST['id']; $result = mysql_query($query, $db) or die (mysql_error($db)); extract(mysql_fetch_assoc($result)); list($width, $height, $type, $attr) = getimagesize($dir . '/' . $image_id . '.jpg'); } if ($_POST['submit'] == 'Save') { // make sure the requested image is valid if (isset($_POST['id']) && ctype_digit($_POST['id']) && file_exists($dir . '/' . $_POST['id'] . '.jpg')) { $image = imagecreatefromjpeg($dir . '/' . $_POST['id'] . '.jpg'); } else { die('invalid image specified'); } // apply the filter $effect = (isset($_POST['effect'])) ? $_POST['effect'] : -1; switch ($effect) { case IMG_FILTER_NEGATE: imagefilter($image, IMG_FILTER_NEGATE); break; case IMG_FILTER_GRAYSCALE: imagefilter($image, IMG_FILTER_GRAYSCALE); break; case IMG_FILTER_EMBOSS: imagefilter($image, IMG_FILTER_EMBOSS); break; case IMG_FILTER_GAUSSIAN_BLUR: imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR); break; } // add the caption if requested if (isset($_POST['emb_caption'])) { imagettftext($image, 12, 0, 20, 20, 0, $font, $image_caption); } //add the logo watermark if requested if (isset($_POST['emb_logo'])) { // determine x and y position to center watermark list($wmk_width, $wmk_height) = getimagesize('images/logo.png'); $x = ($width - $wmk_width) / 2; $y = ($height - $wmk_height) / 2; $wmk = imagecreatefrompng('images/logo.png'); imagecopymerge($image, $wmk, $x, $y, 0, 0, $wmk_width, $wmk_height, 20); imagedestroy($wmk); } // save the image with the filter applied imagejpeg($image, $dir . '/' . $_POST['id'] . '.jpg', 100); //set the dimensions for the thumbnail $thumb_width = $width * 0.10; $thumb_height = $height * 0.10; //create the thumbnail $thumb = imagecreatetruecolor($thumb_width, $thumb_height); imagecopyresampled($thumb, $image, 0, 0, 0, 0, $thumb_width, $thumb_height, $width, $height); imagejpeg($thumb, $dir . '/' . $_POST['id'] . '.jpg', 100); imagedestroy($thumb); ?> <html> <head> <title>Here is your pic!</title> </head> <body> <h1>Your image has been saved!</h1> <img src="images/<?php echo $_POST['id']; ?>.jpg" /> </body> </html> <?php } else { ?> <html> <head> <title>Here is your pic!</title> </head> <body> <h1>So how does it feel to be famous?</h1> <p>Here is the picture you just uploaded to our servers:</p> <?php if ($_POST['submit'] == 'Upload') { $imagename = 'images/' . $image_id . '.jpg'; } else { $imagename = 'image_effect.php?id=' . $image_id . '&e=' . $_POST['effect']; if (isset($_POST['emb_caption'])) { $imagename .= '&capt=' . urlencode($image_caption); } if (isset($_POST['emb_logo'])) { $imagename .= '&logo=1'; } } ?> <img src="<?php echo $imagename; ?>" style="float:left;"> <table> <tr><td>Image Saved as: </td><td><?php echo $image_id . '.jpg'; ?></td></tr> <tr><td>Height: </td><td><?php echo $height; ?></td></tr> <tr><td>Width: </td><td><?php echo $width; ?></td></tr> <tr><td>Upload Date: </td><td><?php echo $image_date; ?></td></tr> </table> <p>You may apply special options to your image below. Note: saving an image with any of the options applied <em>cannot be undone</em>.</p> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <div> <input type="hidden" name="id" value="<?php echo $image_id;?>"/> Filter: <select name="effect"> <option value="-1">None</option> <?php echo '<option value="' . IMG_FILTER_GRAYSCALE . '"'; if (isset($_POST['effect']) && $_POST['effect'] == IMG_FILTER_GRAYSCALE) { echo ' selected="selected"'; } echo '>Black and White</option>'; echo '<option value="' . IMG_FILTER_GAUSSIAN_BLUR . '"'; if (isset($_POST['effect']) && $_POST['effect'] == IMG_FILTER_GAUSSIAN_BLUR) { echo ' selected="selected"'; } echo '>Blur</option>'; echo '<option value="' . IMG_FILTER_EMBOSS . '"'; if (isset($_POST['effect']) && $_POST['effect'] == IMG_FILTER_EMBOSS) { echo ' selected="selected"'; } echo '>Emboss</option>'; echo '<option value="' . IMG_FILTER_NEGATE . '"'; if (isset($_POST['effect']) && $_POST['effect'] == IMG_FILTER_NEGATE) { echo ' selected="selected"'; } echo '>Negative</option>'; ?> </select> <br/><br/> <?php echo '<input type="checkbox" name="emb_caption"'; if (isset($_POST['emb_caption'])) { echo ' checked="checked"'; } echo '>Embed caption in image?'; echo '<br/><br/><input type="checkbox" name="emb_logo"'; if (isset($_POST['emb_logo'])) { echo ' checked="checked"'; } echo '>Embed watermarked logo in image?'; ?> <br/><br/> <input type="submit" value="Preview" name="submit" /> <input type="submit" value="Save" name="submit" /> </div> </form> </body> </html> <?php } ?> Any help appreciated. <td><label for='images'> <b>File to upload:</b> </label></td> <td><input type='file' name = 'drama_image' '<?php echo $row['drama_image']; ?>'/></ </tr> <?php $target_path = "images/"; $target_path = $target_path . basename( $_FILES['images']['name']); if(move_uploaded_file($_FILES['images']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['images']['name']). " has been uploaded"; } else{ echo $row['drama_image']; } ?> ['drama_image'] is the name of the file I wanna echo it out in the box of file upload so when I save , the default picture will still be there instead of being overwritten as the box does not have any value in it. Hello, Can someone help me with these contact-form please, I just want to include a file (.pdf, .jpg, .png) and send the mail.
For the moment, the mail is send but not with the file included.
Here is the website http://www.coeuraprendre.art
HTML CODE :
<form id="contact-form" class="checkform" action="#" target="contact-send.php" method="post" enctype="multipart/form-data" > <div class="form-row clearfix"> <label for="name" class="req">Nom *</label> <input type="text" name="name" class="name" id="name" value="" placeholder="Name" /> </div> <div class="form-row clearfix"> <label for="email" class="req">Email *</label> <input type="text" name="email" class="email" id="email" value="" placeholder="Email"/> </div> <div class="form-row clearfix textbox"> <label for="message" class="req">Nom du projet *</label> <textarea name="message" class="message" id="message" rows="15" cols="50" placeholder="Message"></textarea> </div> <div class="form-row clearfix"> <label for="pdf" class="req">Ajoutez votre dossier d'inscription (Pdf intéractif) *</label> <input type="file" id="pdf" class="pdf" name="pdf" placeholder="Pdf" accept="image/pdf"> </div> <div id="form-note"> <div class="alert alert-error"> <strong>Error</strong>: Please check your entries! </div> </div> <div class="form-row form-submit"> <input type="submit" name="submit_form" class="submit" value="Send" /> </div> <input type="hidden" name="subject" value="From Coeur à Prendre" /> <input type="hidden" name="fields" value="name,email,message," /> <input type="hidden" name="sendto" value="info@coeuraprendre.art" /> </form> </div> <!-- Contact form -->
PHP CODE :
<?php define("WEBMASTER_EMAIL", $_POST['sendto']); if (WEBMASTER_EMAIL == '' || WEBMASTER_EMAIL == 'Testemail') { die('<div class="alert alert-confirm"> <h6><strong>The recipient email is not correct</strong></h6></div>'); } define("EMAIL_SUBJECT", $_POST['subject']); if (EMAIL_SUBJECT == '' || EMAIL_SUBJECT == 'Subject') { define("EMAIL_SUBJECT",'Contact'); } $name = stripslashes($_POST['name']); $email = trim($_POST['email']); $message = stripslashes($_POST['message']); $pdf = stripslashes($_POST['pdf']); $custom = $_POST['fields']; $custom = substr($custom, 0, -1); $custom = explode(',', $custom); $message_addition = ''; foreach ($custom as $c) { if ($c !== 'name' && $c !== 'email' && $c !== 'message' && $c !== 'pdf' && $c !== 'subject') { $message_addition .= '<b>'.$c.'</b>: '.$_POST[$c].'<br />'; } } if ($message_addition !== '') { $message = $message.'<br /><br />'.$message_addition; } $message = '<html><body>'.nl2br($message)."</body></html>"; $mail = mail(WEBMASTER_EMAIL, EMAIL_SUBJECT, $message, "From: ".$name." <".$email.">\r\n" ."Reply-To: ".$email."\r\n" ."X-Mailer: PHP/" . phpversion() ."MIME-Version: 1.0\r\n" ."Content-Type: text/html; charset=utf-8"); if($mail) { echo ' <div class="alert alert-confirm"> <strong>Confirm</strong>: Your message has been sent. Thank you! </div> '; } else { echo ' <div class="alert alert-error"> <strong>Error</strong>: Your message has not been send! </div> '; } ?> Edited July 22 by cocolembo |