doforumda Posted June 14, 2010 Share Posted June 14, 2010 hi i need help in uploading one image to two different directories. How can i do this. My current code is able to upload image to one directory but it does not upload it to second directory. Here is my code <?php session_start(); include("../db/db.php"); include("../functions/getExtension.php"); $image_name = $_FILES['my_photo']['name']; $image_type = $_FILES['my_photo']['type']; $image_size = $_FILES['my_photo']['size']; $image_temp_name = $_FILES['my_photo']['tmp_name']; $error = $_FILES['my_photo']['error']; $album_name = $_POST['album_name']; $ext = getExtension($image_name); $ext = strtolower($ext); if($error == 0) { $location = "photos/user$_SESSION[userid]/".$album_name."/".$image_name; $location_full_image = "photos/user$_SESSION[userid]/".$album_name."_full/".$image_name; if($image_size < 3145728) { //3145728 = 3MB if($ext == "png" || $ext == "jpeg" || $ext == "jpg" || $ext == "gif") { if(!file_exists($location)) { move_uploaded_file($image_temp_name, $location); move_uploaded_file($image_temp_name, $location_full_image); $add_image = mysql_query("INSERT INTO photos VALUES('', '$_SESSION[userid]', '$_SESSION[username]', '$_SESSION[email]', '$album_name', '$location', 'no')") or die(mysql_error()); header("Location: photos.php"); } else echo "Image with the name you specified already exist at location $location. Please upload image with changed name."; } else echo "Only png, jpeg, jpg and gif file formats are allowed to upload."; } else echo "Image size is too big. Your Image must be 3 or less than 3MB."; } else echo "There is an error uploading file. Error Code: $error"; ?> Link to comment https://forums.phpfreaks.com/topic/204722-need-help-in-uploading-image/ Share on other sites More sharing options...
l4nc3r Posted June 14, 2010 Share Posted June 14, 2010 http://tinyurl.com/2dsykco Link to comment https://forums.phpfreaks.com/topic/204722-need-help-in-uploading-image/#findComment-1071805 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.