PHP - Copy Uploaded Files From Domain To Subdomain.
Hi all,
Im trying to move files that im uploading from my main domain to a sub domain. I think I can achieve this using passthru? Im having issues with this, can any one point me in the right direction please? Thanks, Phil Similar Tutorialshey all, I've been struggling with this for the last few days and can't figure it out... I'm trying to build a fairly complex uploading system. the thing i'm getting stuck with is trying to copy/move the uploaded files from the domain name to a subdomain Ex: $path1 = "/var/www/vhosts/domain.com/httpdocs/new/test/test.jpg"; $path2 = "/var/www/vhosts/domain.com/subdomains/img/httpdocs/test/test.jpg"; Dedicated server running RHEL with Plesk The problem seems to be an open_basedir restriction. My question is... are there any work-arounds open_basedir and if not what are the implications of disabling it??? Any help is greatly appreciated. Thank you for your time c Hi, I have a question. Can I actually use windows hosting on .php files, or .php files are only suitable to linux domain? Currently I am practicing some php files in the windows domain and I have received a message stated 'no database selected'. However I have definitely created the database, are there any other reasons which may cause this problem? Thanks <?php echo '<select name="race" id="race"> <option value="">--Please select one--</option>'; $dbc = mysql_connect(111', '111', '111', '111') or die(mysql_error()); $query = ("SELECT * FROM race ORDER BY race_id ASC"); $sql = mysql_query($query, $dbc) or die(mysql_error()); while($data = mysql_fetch_array($sql)) { echo'<option value="'.$data['race_id'].'">'.$data['race_name'].'</option>'; } echo '</select><br/>'; mysql_close($dbc); ?> I'm making an admin so I need to be able to do this: https://admin.mysite.com Run an upload image script from a file, saves image to folder in http://www.mysite.com Image Folder Hi,
I have an address on my main server http://www.website.com/directory and would like to redirect it to a subdomain http://subdomain.website.com/directory
The subdomain is not pointing to the same server as the main domain.
How would I set up a redirect in htaccess?
Thanks!
My service allows users to generate subdomains based off their username(testguy.mydomain.com). I've created a wildcard subdomain for this, so the dynamic subdomains work wonderfully.
I've added a parked domain where my domain is supposed to mirror the given subdomain. However, when I go to the domain.com, it redirects to the subdomain, changing the URL in the address bar. Any ideas?
Or if there a better way to mirror a subdomain while showing the original domain in the address bar?
Edited by fitguydan, 12 June 2014 - 11:57 PM. At the moment I have been uploading files to my server using <input type='files'> and binary encrytion. I would like to have more controll over the files tmp_name. is there a way to assing it befor hand? Hi All, I'm trying to validate file types and keep seeing an error. I only allow .gif, .jpg or .png. However, if I upload any of those file types, I get an error message.... If I echo out $filetypeCheck, I get image/png, which is corrent... Code: [Select] $filetypeCheck = $_FILES["file"]["type"]; if( ($filetypeCheck != "image/gif") || ($filetypeCheck != "image/jpeg") || ($filetypeCheck != "image/png") ) { $val_error[] = 'File Type Error! (.gif, .jpg and .png only)'; } Whats going on here? Is it better to store uploaded images as 'content' in the database? (like he http://www.techsupportforum.com/forums/f49/tutorial-upload-files-to-database-176804.html).. Or just as a regular file which is referenced in the database..? Hello I am using the code:
<?php hi everyone i am currently making my website with an uploadform. The upload function is working, but now i am trying to make the site remember the last 5 uploads. The filenames should appear in an array: $aotf[0] $aotf[1] $aotf[2] $aotf[3] $aotf[4] and since all files that can be/are uploaded are images, i want them to be drawed next to each other, each 128x128. THAT is working, but the fetch for images doesn't. When an image is uploaded, i execute this code: $readhandle=fopen("uploaddb.log","r"); $aotf=fread($handle,filesize("uploaddb.log")); fclose($readhandle); $writehandle=fopen("uploaddb.log","w"); fwrite($writehandle,"$aotf\r\n" . "uploadform/gebruikers/" . $naam); fclose($writehandle); then,there is some html code, and then there is this code: $aotf=explode("/n",$aotf); for($i = count($aotf) - 5; $i <= count($aotf); $i++) { echo ' <img src="'. $aotf[$i] . '" width="128" height="128"> '; } when i open the page, all img src's are empty. The writing works, and the folder of the image is 7777 chmod and the images draw on the screen, but not as the last uploaded. Does anyone know how to make this work? maybe even without a fwrite? Thank you, masterens EDIT: i cannot use mysql Hi, I have limited experience of using PHP, but having done some searching around it would seem that it is possible to convert audio files that are uploaded through a web page to mp3 using ffmpeg. The audio files would be uploaded using the Uploadify script to subfolders that are named according to the user's login. I would need the PHP script to be able to process all audio files that are either not in MP3 format, or are in MP3 format but greater than 192kbps, deleting the original file after the conversion. Am I right in thinking that this could be achieved using PHP, and if so, can anyone get me started with some code, or a link to a webpage with some code? Also, I am currently using Hostpapa for hosting my website, and I understand that they don't include ffmpeg, and also don't allow ssh. I read on one website that I could still install a compiled version of ffmpeg on a shared server, but I am not sure if this means that it would work on Hostpapa, or whether I would need to change my host to get ffmpeg working. Any advice on any of this would be welcome! Thanks, Nick Hi Basically I've built a CMS where by my clients can upload a number of images. On the success page I want to display the images they uploaded by file name. The issue is the number of images can vary. They may upload 2 or 10 or 50 etc. So far I've come up with this: Code: [Select] // number of files $UN = 3; //I've set this to 3 for now, but this is passed from the upload page! // server directories and directory names $dir = '../properties'; $images = glob($dir.'/*.{jpg}', GLOB_BRACE); //formats to look for $num_of_files = $UN; //number of images to display from number of uploaded files foreach($images as $image) { $num_of_files--; $newest_mtime = 0; $image = 'BROKEN'; if ($handle = @opendir($dir)) { while (false !== ($file = readdir($handle))) { if (($file != '.') && ($file != '..')) { $mtime = filemtime("$dir/$file"); if ($mtime > $newest_mtime) { $newest_mtime = $mtime; $image = "$file"; } } } } if($num_of_files > -1) //this made me laugh when I wrote it echo $trimmed = ltrim($image, "../properties").'<br />'; //display images else break; } Without this piece of code: Code: [Select] $newest_mtime = 0; $image = 'BROKEN'; if ($handle = @opendir($dir)) { while (false !== ($file = readdir($handle))) { if (($file != '.') && ($file != '..')) { $mtime = filemtime("$dir/$file"); if ($mtime > $newest_mtime) { $newest_mtime = $mtime; $image = "$file"; } } } } It shows the first 3 files alphabetically. I want to view the last number of images added. With the above code it simply shows the last image added 3 times! So I need to get the time each image was added and then order by the newest added and limit to the number of images uploaded. Any suggestions please? Kindest regards Glynn i am trying to create a small script that will let you
1. Create a PDF from form fields then email that pdf without saving it (was using fpdf for this)
2. within that form there is a file upload - i want to send these along with the pdf crerated in the same email.
this is my code so far, the php sends fine but it is sending in 2 seperate emails and i want it all to send in one
any help would be much apprichated as i am a compleat noob at PHP!
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Email Attachment Without Upload - Excellent Web World</title> <style> body{ font-family:Arial, Helvetica, sans-serif; font-size:13px;} th{ background:#999999; text-align:right; vertical-align:top;} input{ width:181px;} </style> </head> <body> <form action="emailSend.php" method="post" name="mainform" enctype="multipart/form-data"> <table width="500" border="0" cellpadding="5" cellspacing="5"> <tr> <th>Your Name</th> <td><input name="fieldFormName" type="text"></td> </tr> <tr> <tr> <th>Your Email</th> <td><input name="fieldFormEmail" type="text"></td> </tr> <tr> <th>To Email</th> <td><input name="toEmail" type="text"></td> </tr> <tr> <th>Subject</th> <td><input name="fieldSubject" type="text" id="fieldSubject"></td> </tr> <tr> <th>Comments</th> <td><textarea name="fieldDescription" cols="20" rows="4" id="fieldDescription"></textarea></td> </tr> <tr> <th>Attach Your File</th> <td><input name="attachment" type="file"></td> </tr> <tr> <td colspan="2" style="text-align:center;"><input type="submit" name="Submit" value="Send"><input type="reset" name="Reset" value="Reset"></td> </tr> </table> </form> </body> </html> <?php //create PDF and send // download fpdf class (http://fpdf.org) require("fpdf.php"); // fpdf object $pdf = new FPDF(); // generate a simple PDF (for more info, see http://fpdf.org/en/tutorial/) $pdf->AddPage(); $pdf->SetFont("Arial","B",14); $pdf->Cell(40,10, "this is a pdf example"); // email stuff (change data below) $to = "me@domain.com"; $from = "me@domain.com"; $subject = "send email with pdf attachment"; $message = "<p>Please see the attachment.</p>"; // a random hash will be necessary to send mixed content $separator = md5(time()); // carriage return type (we use a PHP end of line constant) $eol = PHP_EOL; // attachment name $filename = "example.pdf"; // encode data (puts attachment in proper format) $pdfdoc = $pdf->Output("", "S"); $attachment = chunk_split(base64_encode($pdfdoc)); // main header (multipart mandatory) $headers = "From: ".$from.$eol; $headers .= "MIME-Version: 1.0".$eol; $headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"".$eol.$eol; $headers .= "Content-Transfer-Encoding: 7bit".$eol; $headers .= "This is a MIME encoded message.".$eol.$eol; // message $headers .= "--".$separator.$eol; $headers .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol; $headers .= "Content-Transfer-Encoding: 8bit".$eol.$eol; $headers .= $message.$eol.$eol; // attachment $headers .= "--".$separator.$eol; $headers .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol; $headers .= "Content-Transfer-Encoding: base64".$eol; $headers .= "Content-Disposition: attachment".$eol.$eol; $headers .= $attachment.$eol.$eol; $headers .= "--".$separator."--"; // send message mail($to, $subject, "", $headers); //send uploaded attachments via email $to = $_POST['toEmail']; $fromEmail = $_POST['fieldFormEmail']; $fromName = $_POST['fieldFormName']; $subject = $_POST['fieldSubject']; $message = $_POST['fieldDescription']; /* GET File Variables */ $tmpName = $_FILES['attachment']['tmp_name']; $fileType = $_FILES['attachment']['type']; $fileName = $_FILES['attachment']['name']; /* Start of headers */ $headers = "From: $fromName"; if (file($tmpName)) { /* Reading file ('rb' = read binary) */ $file = fopen($tmpName,'rb'); $data = fread($file,filesize($tmpName)); fclose($file); /* a boundary string */ $randomVal = md5(time()); $mimeBoundary = "==Multipart_Boundary_x{$randomVal}x"; /* Header for File Attachment */ $headers .= "\nMIME-Version: 1.0\n"; $headers .= "Content-Type: multipart/mixed;\n" ; $headers .= " boundary=\"{$mimeBoundary}\""; /* Multipart Boundary above message */ $message = "This is a multi-part message in MIME format.\n\n" . "--{$mimeBoundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; /* Encoding file data */ $data = chunk_split(base64_encode($data)); /* Adding attchment-file to message*/ $message .= "--{$mimeBoundary}\n" . "Content-Type: {$fileType};\n" . " name=\"{$fileName}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mimeBoundary}--\n"; } $flgchk = mail ("$to", "$subject", "$message", "$headers"); if($flgchk){ echo "A email has been sent to: $to"; } else{ echo "Error in Email sending"; } ?> hey, can some one provide a code to help me copy a folder called contents with files in it to another folder called items cheers I know this code works
INSERT INTO archive_table SELECT * FROM original_table WHERE id = 1But i want to also add the current date whenever i copy the data into a new table. Thanks in advance How would I copy an array of selected files? I know how to list them using a 'for' loop, and how to separate them using a 'foreach' loop, but I am unable to get a checkbox array to copy to a destination folder. Help is appreciated. show list of files uploaded by current session user to the database. I want to show different users when they log in to the website...they can see a list of old files that they have uploaded. can anyone tell me the code/script to this.....please, ty I need to copy php files from remote linux (apache) server to windows usb drive.
I am using php windows but the files were created in php under linux.
Do I just download them or do I need to do something to make this work
|