PHP - Convert Files Into Zip
Hi,
I have songs that I have uploaded. There are tracks in each song. So I want my users to click download and they'll be able to download all of the tracks combined in a zip file. I have seen this hapening on several sites. Can any body tell me how that works using PHP codes / classes Regards, Faisal Similar TutorialsHi I was going to start a new project which need to convert files from one fomrat to other like, you can check a site here online-convert.com , there they give user to convert in various fomats. please check my question is i have idea how to do these conversion with ffmpeg and php. Code: [Select] Audio converter Video converter Image converter Hash generator can someone please tell me how to do these conversion. Code: [Select] Document converter Ebook converter Thanks for any help We have a site that uses archived Realmedia video files, but we would like to have a automated way of converting those uploaded videos into seperate podcats for user download. Is there a way using PHP to do this? I have just started learning PHP and have no idea if this is even possible. I am trying to find out how to convert HTML code to ePub format dynamically, i know it can be done, but i was wondering if anyone had a tutorial i could follow or something, Thanks. 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> So far I have managed to create an upload process which uploads a picture, updates the database on file location and then tries to upload the db a 2nd time to update the Thumbnails file location (i tried updating the thumbnails location in one go and for some reason this causes failure) But the main problem is that it doesn't upload some files Here is my upload.php <?php include 'dbconnect.php'; $statusMsg = ''; $Title = $conn -> real_escape_string($_POST['Title']) ; $BodyText = $conn -> real_escape_string($_POST['ThreadBody']) ; // File upload path $targetDir = "upload/"; $fileName = basename($_FILES["file"]["name"]); $targetFilePath = $targetDir . $fileName; $fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION); $Thumbnail = "upload/Thumbnails/'$fileName'"; if(isset($_POST["submit"]) && !empty($_FILES["file"]["name"])){ // Allow certain file formats $allowTypes = array('jpg','png','jpeg','gif','pdf', "webm", "mp4"); if(in_array($fileType, $allowTypes)){ // Upload file to server if(move_uploaded_file($_FILES["file"]["tmp_name"], $targetFilePath)){ // Insert image file name into database $insert = $conn->query("INSERT into Threads (Title, ThreadBody, filename) VALUES ('$Title', '$BodyText', '$fileName')"); if($insert){ $statusMsg = "The file ".$fileName. " has been uploaded successfully."; $targetFilePathArg = escapeshellarg($targetFilePath); $output=null; $retval=null; //exec("convert $targetFilePathArg -resize 300x200 ./upload/Thumbnails/'$fileName'", $output, $retval); exec("convert $targetFilePathArg -resize 200x200 $Thumbnail", $output, $retval); echo "REturned with status $retval and output:\n" ; if ($retval == null) { echo "Retval is null\n" ; echo "Thumbnail equals $Thumbnail\n" ; } }else{ $statusMsg = "File upload failed, please try again."; } }else{ $statusMsg = "Sorry, there was an error uploading your file."; } }else{ $statusMsg = 'Sorry, only JPG, JPEG, PNG, GIF, mp4, webm & PDF files are allowed to upload.'; } }else{ $statusMsg = 'Please select a file to upload.'; } //Update SQL db by setting the thumbnail column to equal $Thumbnail $update = $conn->query("update Threads set thumbnail = '$Thumbnail' where filename = '$fileName'"); if($update){ $statusMsg = "Updated the thumbnail to sql correctly."; echo $statusMsg ; } else { echo "\n Failed to update Thumbnail. Thumbnail equals $Thumbnail" ; } // Display status message echo $statusMsg; ?> And this does work on most files however it is not working on a 9.9mb png file which is named "test.png" I tested on another 3.3 mb gif file and that failed too? For some reason it returns the following Updated the thumbnail to sql correctly.Updated the thumbnail to sql correctly. Whereas on the files it works on it returns REturned with status 0 and output: Retval is null Thumbnail equals upload/Thumbnails/'rainbow-trh-stache.gif' Failed to update Thumbnail. Thumbnail equals upload/Thumbnails/'rainbow-trh-stache.gif'The file rainbow-trh-stache.gif has been uploaded successfully. Any idea on why this is? Hello I have a simple question about file handling... Is it possible to list all files in directories / subdirectories, and then read ALL files in those dirs, and put the content of their file into an array? Like this: array: [SomePath/test.php] = "All In this php file is being read by a new smart function!"; [SomePath/Weird/hello.txt = "Hello world. This is me and im just trying to get some help!";and so on, until no further files exists in that rootdir. All my attempts went totally crazy and none of them works... therefore i need to ask you for help. Do you have any ideas how to do this? If so, how can I be able to do it? Thanks in Advance, pros I am using WPSQT plugin in my blog site .I code some files in PHP also.how to add that files in plugin files.
How can I echo this as seconds? $date_at_timezone = new DateTimeZone('Asia/Shanghai'); $date = new DateTime(); $date->setTimezone($date_at_timezone); echo $date->format('l dS F Y h:i:s A') . "Asia/Shanghai<br>"; I have the following code in javascript, I would like to rewrite it in PHP, if someone can help thank you very much. my code: http://pastebin.com/Jnt8RiYj Olá,
I have this codE:
$cb = 'str_replace("' . $this->LE . '", "", "<$1>");'; $encoded_value[$key] = preg_replace("/<([^>]+)>/e", $cb, $encoded_value[$key]);error: "PHP message: PHP Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead How can i transform this code to preg_replace_callback ? thanks I have come across a little feature I need to create to be able to upload .doc files and convert them to .pdf using PHP. I was wondering if anyone had any idea how I would go about achieving this, I am not asking for the code, I'm just asking on how it could be accomplished...I've searched Google and other PHP related forums but none have the answer to which I am looking for. Any ideas or suggestions are greatly appreciated. Regards, PaulRyan. Hi Coders,
any body can convert the following code into codeigniter.
if($_GET['type'] == 'country'){ $result = mysql_query("SELECT name FROM country where name LIKE '".strtoupper($_GET['name_startsWith'])."%'"); $data = array(); while ($row = mysql_fetch_array($result)) { array_push($data, $row['name']); } echo json_encode($data); }Thanks Hello I'm building a backend to allow a client to upload images to his site. But my client has a lot of images in tiff format so i'd like to be able to convert tiff to jpg and only after that upload the image. i'm using the command move_uploaded_file to upload the original image and then i'm resizing the image and creating a new one and delete the original. now i want to add to my script a way to convert the original tiff to jpeg, resize save and delete the original here is my code that it's working fine: Code: [Select] if ($_FILES['foto']['name'] == "") { $dir = "images/spacer.gif"; } else { $size = 124; // the thumbnail height $filedir = 'img/ambientes/'; // the directory for the original image $thumbdir = 'img/ambientes/'; // the directory for the thumbnail image $prefix = 'small_'; // the prefix to be added to the original name $maxfile = '200000'; $mode = '0666'; $userfile_name = $_FILES['foto']['name']; $userfile_tmp = $_FILES['foto']['tmp_name']; $userfile_size = $_FILES['foto']['size']; $userfile_type = $_FILES['foto']['type']; if (isset($_FILES['foto']['name'])) { $prod_img = $filedir.$userfile_name; $prod_img_thumb = $thumbdir.$prefix.$userfile_name; move_uploaded_file($userfile_tmp, $prod_img); chmod ($prod_img, octdec($mode)); $sizes = getimagesize($prod_img); $aspect_ratio = $sizes[0]/$sizes[1]; if ($sizes[0] <= $size) { $new_width = $size; $new_height = abs($new_width*$aspect_ratio); }else{ $new_width = $size; $new_height = abs($new_width/$aspect_ratio); } $destimg=ImageCreateTrueColor($new_width,$new_height) or die('Problem In Creating image'); $srcimg=ImageCreateFromJPEG($prod_img) or die('Problem In opening Source Image'); ImageCopyResampled($destimg, $srcimg, 0, 0, 0, 0, $new_width, $new_height, $sizes[0], $sizes[1]) or die('Problem In resampling'); ImageJPEG($destimg,$prod_img_thumb,90) or die('Problem In saving'); $uploadfile = $prod_img_thumb; imagedestroy($destimg); $fh = fopen($prod_img, 'w') or die("can't open file"); fclose($fh); unlink($prod_img); $dir = $uploadfile; } } anyone can help me? Hi, I was wondering if anyone has experience with using php to convert a powerpoint presentation on a Linux OS with Apache web server. The idea would be that a user uploads a powerpoint file that is converted server-side to individual png/jpg files for each slide so that a subset of these slides can be shown as a preview in an image slider. Does anyone know if this can be done on a Linux OS with Apache web server? I came across some solutions for windows versions of php (http://www.php.net/manual/en/com.requirements.php). Hope anyone can help me. Hi. I have a large amount of data in an excel spread sheet. I have isolated 3 rows containing a date (yyyy-mm-dd plus two decimal values). I saved this as a tab delimited text instead of a comma separated csv. What I want to do is read each line of a text file and split it up into 3 and construct an INSERT INTO sql. the problem is this is not separated by comas for a split function. Can I split on a tab instead? I have used commas in the past only. TIA Desmond.
I have some words are written by UTF-8. I want to use PHP to convert them to NCR DECIMAL. This is my words. After Convert: Sorry my bad English. Thanks advance This is TEXT FILE my Source. (attach File) [attachment deleted by admin] I am trying to convert colors from Hex to HSL (Not HSL to Hex). I am using a PHP function for this purpose. But It's not working properly for some colors. For example for #e04c4c the HSL should be (0, 70%, 59%) which it isn't the case with the function. function hexToHsl($hex) { $red = hexdec(substr($hex, 0, 2)) / 255; $green = hexdec(substr($hex, 2, 2)) / 255; $blue = hexdec(substr($hex, 4, 2)) / 255; $cmin = min($red, $green, $blue); $cmax = max($red, $green, $blue); $delta = $cmax - $cmin; if ($delta === 0) { $hue = 0; } elseif ($cmax === $red) { $hue = (($green - $blue) / $delta) % 6; } elseif ($cmax === $green) { $hue = ($blue - $red) / $delta + 2; } else { $hue = ($red - $green) / $delta + 4; } $hue = round($hue * 60); if ($hue < 0) { $hue += 360; } $lightness = (($cmax + $cmin) / 2) * 100; $saturation = $delta === 0 ? 0 : ($delta / (1 - abs(2 * $lightness - 1))) * 100; if ($saturation < 0) { $saturation += 100; } $lightness = round($lightness); $saturation = round($saturation); //return "hsl(${hue}, ${saturation}%, ${lightness}%)"; return array($hue, $saturation, $lightness); }
This is how I used it: $templatePrimaryColor = '#e04c4c'; $templatePrimaryColor = str_replace("#", "",$templatePrimaryColor); list($h,$s,$l) = hexToHsl($templatePrimaryColor); $primaryColor = "hsl(${h}, ${s}%, ${l}%)"; This is the output: echo '<pre>',print_r(hexToHsl($templatePrimaryColor)).'</pre>'; Array ( [0] => 0 [1] => 99 [2] => 59 ) 1 Does anyone know what is the problem there? Thank you. I'm having trouble with a few pages on xcart with the charsets. The problem we're having is that we need to have both utf-8 and iso type charsets as we're getting garbled code on some pages. What I can do is set the utf-8 on all pages and then encode the garbled code into utf-8. Is there a function that does this in PHP or any modules I can use? Thanks Hey guys I'm having a bit of a problem trying to convert this string to UTF-8 encoding Quote 組ですが、 中には5- 6本のおす すめ番組の エッセンス が、ぎっし り詰まって います。 I've used $strTem = mb_convert_encoding($strTem, "UTF-8", "auto"); and while that detects the correct current encoding it doesnt change it at all and utf8_encode doesnt work at all, dont know what to use. Thanks |