Jump to content

krash11554

Members
  • Posts

    59
  • Joined

  • Last visited

Everything posted by krash11554

  1. I have errror 4 which is no file is selected but how come it passes the isset()? if there is no file selected??
  2. I have code that checks if a file is selected do this. But my problem is it is running that code even though i dont have a selected file in a input box. heres the code. if(isset($_FILES['editcar_fileupload']) && empty($_POST) === false){ //check where to start uploading pictures $image_name = $_FILES['editcar_fileupload']['name']; $image_size = $_FILES['editcar_fileupload']['size']; $image_temp = $_FILES['editcar_fileupload']['tmp_name']; $allowed_ext = array('jpg','jpeg','png','gif'); $count = count($image_name); if (isset($image_name) && empty($image_name) === false){ foreach($image_name as $image_names){ $image_ext = strtolower(end(explode('.', $image_names))); if(in_array($image_ext, $allowed_ext) === false && $true === true){ $errors[] = 'File type is not allowed'; } } if($count > 10){ $errors[] = 'You can not upload more than 10 pictures for your car.'; } } } here is the html <input type="file" onchange="this.form.editcar_fakeinput.value = this.value;" name="editcar_fileupload[]" multiple="multiple" id="editcar_fileupload" /> it says the $image_name has values in it but it really dosent.
  3. When i use var_dump(), i get array(0){}.
  4. Yea that's now how it is in the real code I must of did thy when pasting the code. I guess that's not the problem
  5. i have this glob function. here it is $howmanycarpics = glob(" /garage/uploads/cars/15/thumbs/car1"/*.*"); print_r($howmanycarpics); i think this should return all files in that folder but it isnt
  6. Even In gonna use the session for a short time ?
  7. So i have i a post varialbe containg and a id and when you click the submit button it would take you to a different page. I picked up the variable from the first form but how would i keep the information in another variable after i refresh the second page. What i have now is i get the information from the form then when i refresh the page i loose it.
  8. So all iahve to do is put the directory in the function?
  9. I have had this same problem when i started to make to directorys with mdir function. now i am having problems when i use the unlink function. heres the code. unlink('uploads/cars/' . $user_id . '/car' . $car_number . '/'); unlink('uploads/cars/' . $user_id . '/thumbs/car' . $car_number . '/'); I am getting back Warning: rmdir(uploads/cars/15/car1/) [function.rmdir]: Directory not empty inC:\inetpub\wwwroot\garage\phpfunctions\functions.php on line 315 Warning: unlink(uploads/cars/15/thumbs/car1/) [function.unlink]: Permission denied inC:\inetpub\wwwroot\garage\phpfunctions\functions.php on line 317 I have already set all permissions to the root directory idk what else to do. By the way im on IIS. Thanks
  10. So i have a function that i made and cant seem to figure out why its not working. the function should make the image smaller then 650 by 550. function makelargeimage($directory,$image,$destination){ $image_file = $image; $image = $directory.$image; if (file_exists($image)) { $source_size = getimagesize($image); $width = $source_size['width']; $height = $source_size['height']; $max_height = 650; $max_width = 550; switch($source_size['mime']) { case 'image/jpeg': $source = imagecreatefromjpeg($image); break; case 'image/png': $source = imagecreatefrompng($image); break; case 'image/gif': $source = imagecreatefromgif($image); break; } if($width < $max_width && $height < $max_height){ //good }elseif($width > $height){ //longer if($width > $max_width || $height > $max_height){ //longer but bigger then 650x550 for($i = 1; $width >= 650; $i+=.1){ $new_width = $width / $i; $new_height = $height / $i; } } }elseif($width < $height){ //taller if($width > $max_width || $height > $max_height){ //taller but bigger then 650x550 for($i = 1; $width >= 650; $i+=.1){ $new_width = $width / $i; $new_height = $height / $i; } } }elseif($width == $height){ //square if($width > $max_width || $height > $max_height){ //square but bigger then 650x550 for($i = 1; $width >= 650; $i+=.1){ $new_width = $width / $i; $new_height = $height / $i; } } } $large_image = imagecreatetruecolor($new_width, $new_height); switch($source_size['mime']) { case 'image/jpeg': imagejpeg($large_image, $destination.$image_file); break; case 'image/png': imagepng($large_image, $destination.$image_file); break; case 'image/gif': imagegif($large_image, $destination.$image_file); break; } } } heres when i call the function makelargeimage('uploads/cars/15/car1/thumbs/' , kyle.jpg, 'uploads/cars/15/thumbs/car/1/); idk where its going wrong. any help is appreciated
  11. This foreach loop in my function isnt working. It only moves the pictures when $image_temp is one picture, but when $image_temp is an array, i thought it should loop around again and move the other images. i cant seem to figure out why it isnt looping around again. heres the function. function addcar_uploaddata($num_rows,$image_ext,$image_temp,$user_id,$car_data){ $user_id = (int)$user_id; array_walk($car_data, 'array_sanitize'); $fields = '`' . implode('`, `', array_keys($car_data)) . '`'; $data = '\'' . implode('\', \'', $car_data) . '\''; mysql_query("INSERT INTO cars ($fields) VALUES ($data)"); $num_rows = $num_rows + 1; $car_id = mysql_insert_id(); $car_file = $car_id . '.' . $image_ext; mkdir('uploads/cars/' . $_SESSION['user_id'] . '/car' . $num_rows,0744); mkdir('uploads/cars/' . $_SESSION['user_id'] . '/thumbs',0744); foreach($image_temp as $image_temps){ move_uploaded_file($image_temps, 'uploads/cars/' . $_SESSION['user_id'] . '/car' . $num_rows . '/' . $car_file); create_thumb('uploads/cars/' . $_SESSION['user_id'] . '/' . 'car' . $num_rows , $car_file, 'uploads/cars/' . $_SESSION['user_id'] . 'thumbs/',150,150); } } allot of the function you dont need to see but i put it in anyway
  12. I know about mkdir function but that only makes a directory, i think. Is there a way to add a folder to a directory? Thanks
  13. This is why im confused bc idk anything you just said hahah. if you can explain it a little more it would probably help. thanks.
  14. Im using the thumbnail function and im getting back Warning: imagejpeg() [function.imagejpeg]: Unable to open 'uploads/profilepics/kyle.jpg' for writing: Permission denied in C:\inetpub\wwwroot\garage\phpfunctions\thumb.func.php on line 49. i dont think it has to do with the code. Any help is appreciated.
  15. When i choose three files to upload everything works. the code displays the name but whenever i select more then three files it dosent display the names. if(isset($_FILES['addcar_fileupload']) && empty($_POST) === false){ $image_name = $_FILES['addcar_fileupload']['name']; $image_size = $_FILES['addcar_fileupload']['size']; $image_temp = $_FILES['addcar_fileupload']['tmp_name']; $allowed_ext = array('jpg','jpeg','png','gif'); if (isset($image_name)){ foreach($image_name as $image_names){ $img_ext = strtolower(end(explode('.', $image_names))); $count = count($image_name); echo $image_names; } } } Any help is appreciated!
  16. Yea i think your asking like outputting html?? and if so, yes im trying to output html and the image.
  17. Hello all i have made a thumnail function and i think the function is working but it has to do with header. here is the function function create_thumbnail($path,$save,$width,$height){ $info = getimagesize($path); $size = array($info[0], $info[1]); if ($info['mime'] == 'image/png'){ $src = imagecreatefrompng($path); }elseif($info['mime'] == 'image/jpeg'){ $src = imagecreatefromjpeg($path); }elseif($info['mime'] == 'image/gif'){ $src = imagecreatefromgif($path); }else{ return false; } $thumb = imagecreatetruecolor($width,$height); $src_aspect = $size[0] / $size[1]; $thumb_aspect = $width / $height; if($src_aspect < $thumb_aspect){ //narrower $scale = $width / $size[0]; $new_size = array($width, $width / $src_aspect); $src_pos = array(0, ($size[1] * $scale - $height) / $scale / 2 ); }elseif($src_aspect > $thumb_aspect){ //wider $scale = $height / $size[1]; $new_size = array($height * $src_aspect, $height); $src_pos = array(($size[0] * $scale - $height) / $scale / 2,0); }else{ //same shape $new_size = array($width, $height); $src_pos = array(0,0); } $new_size[0] = max($new_size[0], 1); $new_size[1] = max($new_size[1], 1); imagecopyresampled($thumb, $src, 0,0, $src_pos[0], $src_pos[1], $new_size[0], $new_size[1],$size[0],$size[1]); if($save === false){ return imagejpeg($thumb); }else{ return imagejpeg($thumb, $save); } } here is the top of my php file where the header is . include "{$_SERVER['DOCUMENT_ROOT']}/garage/core/init.php"; protect_page(); header('Content-Type: image/jpeg'); include "{$_SERVER['DOCUMENT_ROOT']}/garage/includes/overall/overallheader.php"; create_ the create_thumbnail("kyle.jpg",false,100,100); would be further down in the code. i am running on localhost with iis by the way thanks
  18. is there anyway when you upload the picture you can change the file name? then i would put the picture in a file system.
  19. I already have most of the systems made from previous projects i just have to apply to the new project.
  20. After you finish designing website what systems to you apply first. Just want to know other peoples opnions. I would probably put the Login and Register system first.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.