PHP - Cannot Get Move_uploaded_file To Work Properly
For the life of me, I cannot get an uploaded file to move from the tmp folder to the uploads folder. I have made sure all permissions were set to allow for the transfer. $upfile points to the right folder and file.
print_r($_FILES); yields the following: Array ( [userfile] => Array ( [name] => 02.jpg [type] => image/jpeg [tmp_name] => /tmp/phpClFyXP [error] => 0 [size] => 121200 ) ) Any help would be greatly appreciated. HTML: Code: [Select] <html> <head></head> <body> <form enctype="multipart/form-data" action="upload.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value = "2000000000"> Upload this file: <input name ="userfile" type="file"> <input type="submit" value="Send File"> </form> </body> </html> PHP: <html> <head> <title>Uploading...</title> </head> <body> <h1>Uploading file...</h1> <?php if ($_FILES['userfile']['error'] > 0) { echo 'Problem: '; switch ($_FILES['userfile']['error']) { case 1: echo 'File exceeded upload_max_filesize'; break; case 2: echo 'File exceeded max_file_size'; break; case 3: echo 'File only partially uploaded'; break; case 4: echo 'No file uploaded'; break; } exit; } // Does the file have the right MIME type? // put the file where we'd like it $upfile = '/timporn/uploads/'.$_FILES['userfile']['name']; echo $upfile; if (is_uploaded_file($_FILES['userfile']['tmp_name'])) { if (!move_uploaded_file($_FILES['userfile']['tmp_name'], $upfile)) { echo '<br>Problem: Could not move file to destination directory'; exit; } } else { echo 'Problem: Possible file upload attack. Filename: '; echo $_FILES['userfile']['name']; exit; } echo 'File uploaded successfully<br><br>'; // reformat the file contents $fp = fopen($upfile, 'r'); $contents = fread ($fp, filesize ($upfile)); fclose ($fp); $contents = strip_tags($contents); $fp = fopen($upfile, 'w'); fwrite($fp, $contents); fclose($fp); // show what was uploaded echo 'Preview of uploaded file contents:<br><hr>'; echo $contents; echo '<br><hr>'; ?> </body> </html> Similar Tutorialswhy aint this working?? Code: [Select] <?php if ($_COOKIE['watch_id']){ $cookie = $_COOKIE['watch_id']; $cookie_query = mysql_query("SELECT * FROM user WHERE cookie='$cookie'"); if (mysql_num_rows($cookie_query) >= 1){ ?> <li><a href="/index.php">Home</a></li> <li><a href="/cpanel.php">C-Panel</a></li> <li><a href="/logout.php">Logout</a></li> pass <?php } if (mysql_num_rows($cookie_query) <= 1){ ?> <li><a href="register.php">Register</a></li> <li><a href="#" onclick="OPEN_login();">Login</a></li> <li><a href="index.php">Home</a></li> fail1 <?php } } if(!$_COOKIE['watch_id']){ ?> <li><a href="register.php">Register</a></li> <li><a href="#" onclick="OPEN_login();">Login</a></li> <li><a href="/index.php">Home</a></li> fail2 <?php } ?> i have checked in the browser and the cookies match but it always echos fail2 which means that this line is returning false: Code: [Select] if ($_COOKIE['watch_id']){ i have tried using isset but that didnt help either! any help? Hello,
I have one search form and when I search something the result is whole records from the database not only the search term. Any help is appreciated. I will post only the part where is calculating the rows from db but if need I will post whole pagination script.
$searchTerm = trim($_POST['term']); $adjacents = 3; $sql1 = mysql_query("SELECT * FROM images ORDER BY id ASC"); $nr = mysql_num_rows($sql1); $limit = 6; $targetpage = "search.php"; $page = $_GET['page']; if($page) $start = ($page - 1) * $limit; else $start = 0; if ($page == 0) $page = 1; $prev = $page - 1; // $prev = $page - 1 $next = $page + 1; // $next = $page + 1 $lastpage = ceil($nr/$limit); //lastpage = total pages / items per page. $lpm1 = $lastpage - 1; $pagination = ""; .... .... // pagination ... ... // while loop for the results $sql = "SELECT id, name, caption FROM images WHERE caption LIKE '%".$searchTerm."%' ORDER BY id DESC LIMIT $start, $limit"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { $output.= "<div class=\"container_image\">"; $output.= "<a href=\"/pic-".$row['id'].".html\"><img src=\"/upload/".$row['name']."\" width=\"210\" height=\"150\"/></a>"; $output.= "</div>"; } Edited by vinsb, 21 July 2014 - 06:58 AM. I cannot get my script to update table: locations_all column city_state to the full state name.. Here's what I've been hacking at for 4.5 hours now! Ready to hit the sack.. Thanks for any input: $state_list = array('AL' => "Alabama", 'AK' => "Alaska", 'AZ' => "Arizona", 'AR' => "Arkansas", 'CA' => "California", 'CO' => "Colorado", 'CT' => "Connecticut", 'DE' => "Delaware", 'DC' => "District Of Columbia", 'FL' => "Florida", 'GA' => "Georgia", 'HI' => "Hawaii", 'ID' => "Idaho", 'IL' => "Illinois", 'IN' => "Indiana", 'IA' => "Iowa", 'KS' => "Kansas", 'KY' => "Kentucky", 'LA' => "Louisiana", 'ME' => "Maine", 'MD' => "Maryland", 'MA' => "Massachusetts", 'MI' => "Michigan", 'MN' => "Minnesota", 'MS' => "Mississippi", 'MO' => "Missouri", 'MT' => "Montana", 'NE' => "Nebraska", 'NV' => "Nevada", 'NH' => "New Hampshire", 'NJ' => "New Jersey", 'NM' => "New Mexico", 'NY' => "New York", 'NC' => "North Carolina", 'ND' => "North Dakota", 'OH' => "Ohio", 'OK' => "Oklahoma", 'OR' => "Oregon", 'PA' => "Pennsylvania", 'RI' => "Rhode Island", 'SC' => "South Carolina", 'SD' => "South Dakota", 'TN' => "Tennessee", 'TX' => "Texas", 'UT' => "Utah", 'VT' => "Vermont", 'VA' => "Virginia", 'WA' => "Washington", 'WV' => "West Virginia", 'WI' => "Wisconsin", 'WY' => "Wyoming"); foreach ($state_list as $key => $value) { // get all state abbr and name values. while ($row = mysqli_fetch_array($result)) { $query2 = "UPDATE locations_all SET city_state=$value WHERE city_state=$key"; $result2 = mysqli_query($cxn, $query2) or die("MySQL error: " . mysqli_error($cxn) . "<hr>\nQuery: $query2"); } //while ($row = mysqli_fetch_array($result)) } //foreach ($state_list as $key => $value) I'm able to get the image file name in the database, the image to the right place BUT the problem is the image is totally black and after it's uploaded, a whole bunch of warnings appear. Here are the warnings: Warning: getimagesize(image_files/image-16.jpg) [function.getimagesize]: failed to open stream: No such file or directory in C:\Desktop\xampp\htdocs\image-crop-demo.php on line 37 Warning: Division by zero in C:\Desktop\xampp\htdocs\image-crop-demo.php on line 54 Warning: Division by zero in C:\Users\Samantha\Desktop\xampp\htdocs\image-crop-demo.php on line 71 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in C:\Desktop\xampp\htdocs\image-crop-demo.php on line 78 Warning: imagecopyresampled() expects parameter 1 to be resource, boolean given in C:\Desktop\xampp\htdocs\image-crop-demo.php on line 86 Warning: imagecopy() expects parameter 2 to be resource, boolean given in C:\Desktop\xampp\htdocs\image-crop-demo.php on line 102 Here is the form: <form action="image-crop-demo.php?username=<?php echo $username ?>" method="post" enctype="multipart/form-data"> Upload an image for processing<br> <input type="file" name="Image1"><br> <input type="submit" value="Upload"> </form> And here is the form action file: $username = $_GET['username']; define( 'DESIRED_IMAGE_WIDTH', 150 ); define( 'DESIRED_IMAGE_HEIGHT', 150 ); $source_path = $_FILES[ 'Image1' ][ 'name' ]; $sql="UPDATE thumbnail SET Image1='$source_path' WHERE username = '$username'"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } else { // // Add file validation code here // list( $source_width, $source_height, $source_type ) = getimagesize( $source_path ); switch ( $source_type ) { case IMAGETYPE_GIF: $source_gdim = imagecreatefromgif( $source_path ); break; case IMAGETYPE_JPEG: $source_gdim = imagecreatefromjpeg( $source_path ); break; case IMAGETYPE_PNG: $source_gdim = imagecreatefrompng( $source_path ); break; } $source_aspect_ratio = $source_width / $source_height; $desired_aspect_ratio = DESIRED_IMAGE_WIDTH / DESIRED_IMAGE_HEIGHT; if ( $source_aspect_ratio > $desired_aspect_ratio ) { // // Triggered when source image is wider // $temp_height = DESIRED_IMAGE_HEIGHT; $temp_width = ( int ) ( DESIRED_IMAGE_HEIGHT * $source_aspect_ratio ); } else { // // Triggered otherwise (i.e. source image is similar or taller) // $temp_width = DESIRED_IMAGE_WIDTH; $temp_height = ( int ) ( DESIRED_IMAGE_WIDTH / $source_aspect_ratio ); } // // Resize the image into a temporary GD image // $temp_gdim = imagecreatetruecolor( $temp_width, $temp_height ); imagecopyresampled( $temp_gdim, $source_gdim, 0, 0, 0, 0, $temp_width, $temp_height, $source_width, $source_height ); // // Copy cropped region from temporary image into the desired GD image // $x0 = ( $temp_width - DESIRED_IMAGE_WIDTH ) / 2; $y0 = ( $temp_height - DESIRED_IMAGE_HEIGHT ) / 2; $desired_gdim = imagecreatetruecolor( DESIRED_IMAGE_WIDTH, DESIRED_IMAGE_HEIGHT ); imagecopy( $desired_gdim, $temp_gdim, 0, 0, $x0, $y0, DESIRED_IMAGE_WIDTH, DESIRED_IMAGE_HEIGHT ); // // Render the image // Alternatively, you can save the image in file-system or database $remote_file = "image_files/".$_FILES["Image1"]["name"]; imagejpeg($desired_gdim,$remote_file); }// Hi guys, I have stuck with this issue for over 3 hours now. My remove all button just wouldn't work.
Can anyone tell me what's the issue? I have 2 pages, one parent and another pop-up page that takes the values (cartSubmit) from parent. And I wrote out the code for both pages but I just cannot get it to work.
I apologize in advanced if my code looks messy or doesn't make any sense.
Please take a look at the code and let me know if you could spot anything wrong with it. Any help is greatly appreciated.
Here is the code related to the remove all button in the parent page:
if(isset($_POST['finalSelected'])) { echo "<br/>inside"; if(!empty($_POST['fSelected'])) { echo "<br/>if NOT empty"; $chosen = $_POST['fSelected']; foreach ($chosen as $item) echo "</br>aID selected: $item </br>"; //implode function to transform an array to a string //chosen(array) to $delimit(String) $delimitStr = implode(", ", $chosen); //Save the selected String to SESSION if(!isset($_SESSION["final"])) { $_SESSION["final"] .= "$delimitStr"; } else { $_SESSION["final"] .= ", $delimitStr"; } //Explode function to transform the SESSION variable back to an array for further trimming. $arraySession = explode(', ', $_SESSION["final"]); //Array unique to filter out duplicates. $uniqueArray = array_unique($arraySession); $cartSubmit = implode(", ",$uniqueArray); $_SESSION['cartSubmit'] = $cartSubmit; } else { echo "<br/>else empty"; $noSubmit = $_SESSION["final"]; //Explode function to transform the SESSION variable back to an array for further trimming. $arraySession = explode(', ', $_SESSION["final"]); //Array unique to filter out duplicates. $uniqueArray = array_unique($arraySession); $cartSubmit = implode(", ",$uniqueArray); $_SESSION['cartSubmit'] = $cartSubmit; } } <form name= "finalForm" method="POST" action="test6-1.php" target = "_self"> <input type="Submit" name="finalSelected"/> <a href="javascript:popup('test6-3.php?aID= <?php if(empty($_SESSION['final']) && empty($_SESSION['cartSubmit'])) echo "0"; else if(empty($cartSubmit)) echo "0"; else echo $_SESSION['cartSubmit'];?>')">Cart</a> <?php if(isset($FinalName)) { foreach($FinalName as $key => $item) {?> <tr><td> <input type="checkbox" name="fSelected[]" value="<?php echo htmlspecialchars($FinalID[$key])?>" /> <?php echo "$FinalID[$key] & $item";?> </td></tr> <?php } }?> </form>And here is the code in the pop-up page. <script> window.onunload = refreshParent; function refreshParent() { window.opener.location.reload(); } </script> if(isset($_POST['removeAll'])) { $aID = "0"; unset($_SESSION['cartSubmit']); unset($_SESSION['final']); header("Location : test6-3.php?aID=0"); } Edited by Cyjm1120, 18 November 2014 - 12:16 PM. HI, according to my knowledge session_destroy() function would destroy all session variables and mysql_close() would close connection with the database. i make a simply logoff.php file and close myssql connection and destroy session. but i still get values from the database and session variables. and doesnt work properly here is the code Code: [Select] <?php session_start(); /* * To change this template, choose Tools | Templates * and open the template in the editor. */ require_once '../database/db_connecting.php'; $dbname="sahansevena";//set database name $con= setConnections();//make connections use implemented methode in db_connectiong.php mysql_select_db($dbname, $con); //update the time and date of the admin table $update_time="update admin set last_logged_date =CURDATE(), last_log_time=CURTIME() where username='$uname'limit 3,4"; //my admin table contain 5 colums they are id, username,password, last_logged_date, last_log_time $link= mysql_query($update_time); // mysql_select_db($dbname, $link); //$con=mysql_connect('localhost', 'root','ijts'); $result="select * from admin where username='a'"; $result=mysql_query($result); mysql_close($con); //here i just check after closing data baseconnection whether i do get reselts but i do, why? echo "after the cnnection was closed"; echo "<html>"; echo "<table border='1' cellspacing='1' cellpadding='2' align='center'>"; echo "<thead>"; echo"<tr>"; echo "<th>"; echo ID; echo"</th>"; echo" <th>";echo Username; echo"</th>"; echo"<th>";echo Password; echo"</th>"; echo"<th>";echo Last_logged_date; echo "</th>"; echo "<th>";echo Last_logged_time; echo "</th>"; echo" </tr>"; echo" </thead>"; echo" <tbody>"; while($row= mysql_fetch_array($result,MYSQL_BOTH)){ echo "<tr>"; echo "<td>"; echo $row[0]; echo "</td>"; echo "<td>"; echo $row[1]; echo "</td>"; echo "<td>"; echo $row[2]; echo "</td>"; echo "<td>"; echo $row[3]; echo "</td>"; echo "<td>"; echo $row[4]; echo "</td>"; echo "</tr>"; } echo" </tbody>"; echo "</table>"; echo "</html>"; session_destroy(); session_commit(); echo "session and database are closed but i still get values".$_SESSION['admin']; ?> I am currently creating a multi-user login system, and I have created the database in MySQL, but the problem is that my PHP script is not working as expected. I would like it so that if the user enters in a correct username + password combination, then they are redirected to a webpage called "congrats.php" for example. However, with my current PHP code, if I include a redirection instruction based on the correct input, then when I run the script, then the user is instantly taken to the congrats.php page without filling in any login details. I'm quite sure that the database has been connected to, as due to the layout of my script at the moment, the text that reads "You did it!" appears 4 times, the same number of rows in my MySQL database. My PHP coding for this is: Code: [Select] <html><head><title>Multi-User Log In Form</title></head> <body> <?php $self = $_SERVER['PHP_SELF']; $username = $_POST['username']; $password = $_POST['password']; ?> <form action = "<?php echo $self; ?>" method = "post"> Username <input type = "text" name = "username" size = "8"> Password <input type = "password" name = "password" size = "8"> <input type = "submit" value="Submit"> </form> <?php $conn = @mysql_connect("localhost", "root", "") or die ("Err: Conn"); $rs = @mysql_select_db("test3", $conn) or die ("Err: Db"); $sql = "select * from users"; $rs = mysql_query($sql, $conn); while ($row = mysql_fetch_array($rs)) { $name = $row["uname"]; $pass = $row["pword"]; if ($username = $name && $password = $pass) { //CODE FOR REDIRECTION SHOULD GO HERE //header("location:congrats.php"); echo "You did it!"; } else { echo "Invalid username and password combination"; } } ?></body> </html> Any help in trying to get it so that my PHP script will redirect only if a correct username + password combination is entered would be greatly appreciated I have been trying to upload videos using the move_uploaded_file function but have come up with a new error which is displayed below. Warning: move_uploaded_file(/home/~unn_s003539/public_html/Sold/uploadsPC45 close up .jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /var/www/vhosts/numyspace.co.uk/web_users/home/~unn_s003539/public_html/Sold/vidupload.php on line 25 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpUWYU51' to '/home/~unn_s003539/public_html/Sold/uploadsPC45 close up .jpg' in /var/www/vhosts/numyspace.co.uk/web_users/home/~unn_s003539/public_html/Sold/vidupload.php on line 25 Error when uploading the video./var/www/vhosts/numyspace.co.uk/httpdocs I don't understand why this error is occuring as the file target I'm using is exactly the same as the one in the ftp file which I have just copied across. My code looks like this: session_start(); include("connection.php"); $target = "/home/~unn_s003539/public_html/Sold/uploads"; $target = $target . basename( $_FILES['video']['name']); $name=$_POST['name']; $email=$_POST['email']; $title=$_POST['title']; $description = $_POST['description']; $pic=($_FILES['video']['name']); $sql="INSERT INTO `videos` (name, date, email, title, description, video) VALUES ('$name','CURDATE()', '$email', '$title', '$description','$pic')" ; $result=mysql_query($sql); if(move_uploaded_file($_FILES['video']['tmp_name'], $target)) { echo "Successful upload of ". basename( $_FILES['video']['name']); } else{ echo "Error when uploading the video."; }. Any Help would be greatly appreciated. Im trying to use move_uploaded_file() to move an uploaded file from the temp directory to a different directory and when I run this function I get this error: Quote Warning: move_uploaded_file(/home/mikeh/public_html/uzErUpl0ds/jx8zmPQW.rtf) [function.move-uploaded-file]: failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/fileupload.php on line 238 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/Applications/XAMPP/xamppfiles/temp/phprQRBDe' to '/home/mikeh/public_html/uzErUpl0ds/jx8zmPQW.rtf' in /Applications/XAMPP/xamppfiles/htdocs/fileupload.php on line 238 There was an error uploading the file, please try again! I have no idea why, below is my code: Code: [Select] <?php $target_path = $uploadLocation . basename( $_FILES['upfile']['name']); $ext = end(explode('.', $_FILES['upfile']['name'])); function generatePassword ($length = 8) { // start with a blank password $password = ""; // define possible characters - any character in this string can be // picked for use in the password, so if you want to put vowels back in // or add special characters such as exclamation marks, this is where // you should do it $possible = "_12346789abcdfghjkmnpqrtvwxyzABCDFGHJKLMNPQRTVWXYZ"; // we refer to the length of $possible a few times, so let's grab it now $maxlength = strlen($possible); // check for length overflow and truncate if necessary if ($length > $maxlength) { $length = $maxlength; } // set up a counter for how many characters are in the password so far $i = 0; // add random characters to $password until $length is reached while ($i < $length) { // pick a random character from the possible ones $char = substr($possible, mt_rand(0, $maxlength-1), 1); // have we already used this character in $password? if (!strstr($password, $char)) { // no, so it's OK to add it onto the end of whatever we've already got... $password .= $char; // ... and increase the counter by one $i++; } } // done! return $password; } $filename = generatePassword(); $filename = $filename.".".$ext; $filelocation = "/home/mikeh/public_html/uzErUpl0ds/".$filename; $allowed = "doc docx rtf txt pdf xls"; $allow = explode (" ",$allowed); if (in_array($ext,$allow)){ if(move_uploaded_file($_FILES['upfile']['tmp_name'], $filelocation)) { //TODO: Insert date regex format and make the catagory selection auto// $uid = $_POST['catagory']; $name =$_POST['title']; $author = $_POST['author']; $cat = $_POST['code']; $dt1=date("Y-m-d"); $size = filesize($filelocation); die($filelocation); $query = "INSERT INTO newnotes (uid, name, catagory, location, author, date, filesize) VALUES ('$uid', '$name', '$cat', '$filename', '$author', '$dt1','size')"; //die ($query); $res = mysql_query($query) or die (mysql_error()); echo "The file: ". basename( $_FILES['upfile']['name']). " has been uploaded! It will be reviewed and if possible you will be granted credits within the next 24 hours."; } else{ echo "There was an error uploading the file, please try again!"; } }else{ echo "You have tried to upload an file type that we do not allow. The current allowed types of files are, ".implode(',',$allow).". If you are trying to upload a note with a diffrent file extension please use <a href=\"contact.php\">this form</a> to let us know so we can fix our website to allow this type of file in the future."; } ?> move_uploaded_file($_POST['file']['tmp_name'], "upload/"); doesn't work and if i echo the tmp name it comes up with the first letter of the uploaded file. please help! Howdy! I have been working in this custom script to manage some people on a group.. It will be really complete, with profiles, related stats and also an simple email client. But recently I have been having an issue with the function move_uploaded_file() to upload a picture to the user's profile. Apparently it works for some files (which means the syntax and paths are correct), but for some others move_uploaded_file() returns FALSE and I just can't work it out. Here is the part of the script that treats the uploading: Code: [Select] $target_path = "/opt/lampp/htdocs/emp/deeper/profiles/avt/"; //>>PATH<< to avt folder if (!isAllowedAvatar($_FILES['picture']['name'])) { //Check for allowed filetypes print "<div class='notif error bloc'><strong>Error :</strong> Wrong filetype. Image must be PNG file...</a></div>"; die; } if (file_exists($target_path.$basename.".png")) { //Rename old image to prevent loss of it in case of Failure rename($target_path.$basename.".png",$target_path.$basename."_temp.png"); } $old_path = $target_path; $target_path = $target_path . $basename . ".png"; //Build new image path if(move_uploaded_file($_FILES['picture']['tmp_name'], $target_path)) { //Moves uploaded image print "File ". basename($_FILES['picture']['name'])." correctly uploaded"; unlink($old_path.$basename."_temp.png"); //Deletes temp file } else { print "There was an error uploading the file, please try again!"; rename($old_path.$basename."_temp.png",$old_path.$basename.".png"); //Reverts the temp file to the original } I think the comments are enough for understanding it. Also, it looks like move_uploaded_file() is returning FALSE if the file is from Linux and had ownership stuff.. Any tip is welcome! Thanks for reading! Hi guys, I'm a newbie in php programming and i would like to ask you guys about my issue... am trying to do a script that deletes a file from server and then upload an image to the server... unfortunately it doesn't work... i was able to get the upload part but after putting in the unlink() it doesn't work... the file is deleted from the server however it upload doesn't... hope you guys can assist me with this... thanks in advance... if(file_exists($file_src)){ unlink($file_src); } if(!empty($_FILES['userfile']['name'])){ //file variables $file_name = $_FILES['userfile']['name']; $temp_name = $_FILES['userfile']['tmp_name']; $file_type = $_FILES['userfile']['type']; //get extension of the file $base = basename($file_name); $extension = substr($base, strlen($base)-4, strlen($base)); //only these file types will be allowed $allowed_extensions = array(".txt", "docx", ".doc"); //check that this file type is allowed if(!in_array($extension,$allowed_extensions)){ header('Location:modify.php?action=errorupload&id='.$row['index']); } else{ move_uploaded_file($_FILES['userfile']['tmp_name'], "../files/" . $_FILES['userfile']['name']); $sql2 = "UPDATE t_board SET `writer` = '".$this->writer."', `subject` = '".$this->subject."', `message` = '".$this->message."', `filename` = '".$this->files['name']."' WHERE `index` = '".$this->id."'"; $query2 = mysql_query($sql2); $sql3 = "SELECT * FROM t_board WHERE `index` = '".$this->id."'"; $query3 = mysql_query($sql3); $row2 = mysql_fetch_array($query3); header("Location: view.php?action=edited&writer=".$row2['index']); }//in_array I upload an image and put every information inside $_SESSION['tmp'] and $_SESSION['path'] then once user click on button then i use move_uploaded_file($_SESSION['tmp'],$_SESSION['path']) but file uploaded not appeared in my upload folder, and again i try to echo everything but all information still kept well in $_SESSION is there something missing here? thanks I used the move_uploaded_file function to upload files to my server ,but the function changes the Arabic names of files because most of my files are Arabic named
how can I fix that ?
Hi.., I use below method to export data to excel. header('Content-type: application/ms-excel'); header('Content-Disposition: attachment; filename=abc.xls'); if I run the script from the server. (http://localhost/export.php) it is work. (pop-up window if i want save or open the file) but if i run the script from the client (http://192.168.1.5/export.php) it is not work. (nothing happen) any idea how to solve this? This one requires lots of up front information: I have a page, for this example that I will call page.php. It takes get parameters, and for this example I'll call the parameter "step". So I have a URL like this: page.php?step=1 This page has a form with an action of page.php?step=1. The code on the page validates the posting information. If the information is bad, it returns the user to page.php?step=1; if it is good, it takes the user to page.php?step=2 via header( "location:page.php?step=2" ). So redirection is done by relative path, not full URLs. This all works as expected. Now what I've done is set .htaccess to be HTTPS for this page, via this code: # Turn SSL on for payments RewriteCond %{HTTPS} off RewriteCond %{SCRIPT_FILENAME} \/page\.php [NC] RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L] This works (initially). However, once you try to post the form, it just redirects back to the step=1 version of the page. I really don't know how or why that would be. I'm not sure how else I can explain this or what other information you may have. But it's frustrating to not get a page working in HTTPS that works in HTTP. Very odd. Any suggestions? (I don't even really know the best location to figure out when/why it's redirecting back to the original page.) require_once 'includes/upload.class.php'; $upload = new uploads(); $details = $upload->getFileInformation($id); <?php echo $details['upload_desc']; ?> then here the class. require_once 'db.class.php'; class uploads extends database { private $uploadData; function uploadFile() { public function getFileInformation($id) { $this->uploadData = $this->readData("uploadfiles", "upload_id", $id); return $this->uploadData; } But it wont work! |