Jump to content

co.ador

Members
  • Posts

    726
  • Joined

  • Last visited

    Never

About co.ador

  • Birthday 09/18/1981

Profile Information

  • Gender
    Male
  • Location
    NY

co.ador's Achievements

Advanced Member

Advanced Member (4/5)

0

Reputation

  1. MGA never mind it was inserting all this time even before the thing is I was using $id = SESSION['user_id']; and I needed $product_id = $_POST['product_id']; Sorry for the inconvenience. Thank you for your post.
  2. @MGA ok, i can see how you did directly. now, When i submitted the form it print "File is valid, and was successfully uploaded" but when I go to the inventory_images I don't find neither the orginal file name or the renamed one which would be 194.jpg which was the id created this time. I have the script set up to echo the $id variale after form has submitted but I don't see the file.
  3. mga I just put a snipet of the whole code but the $id is all the way in the code and it is echoing. I will try your suggestion.
  4. The Global $_FILE field value is <?php basename($_FILES['file']['name'] ?> the variable value is <?php $newname = $id . ".jpg" ?> The Field "file" is carry a value of a picture for instance penguin.jpg and then I want to replace that name for $id . ".jpg" to make a new name for the file and replace it for the id fo the product like 34.jpg. I am working on an upload file script so far is moving the file but with the original name and I trying to make a new and rename it to the id of the product the script is as below and so far is inserting the original name of the file in $uploaddir . basename($_FILES['file']['name'] instead I am looking for something like $uuploaddir . $newname which #newname is equal to $id. "jpg" <?php // $newname = $id . ".jpg"; $uploaddir = '/home3/ny/public_html/your/inventory_images/'; $uploadfile = $uploaddir . basename($_FILES['file']['name']); if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) { echo "File is valid, and was successfully uploaded.\n"; } else { echo "File was not uploaded\n"; } ?> Any suggestions? so far as I said the existing code is uploading but with the original name file.
  5. Guys thanks.. PMF thank you for the steps they help me I did all of them I declared and filter all the variables before validation and then process the image move_uploaded_ifle and the data field insert and worked much better. After the script check there is not error or Variable $errors is === 0 then I executed the move_uploaded script function. I realized too that the path was not being specified correctly I needed to specified from the root level. I just need to replace basename($_FILES['file']['name']) for $newname = $id.".jpg"; so that the name of the picture is equal to the id of the product. <?php if (0 === count($errors)){ // $newname = $id . ".jpg"; $uploaddir = '/home3/nyh/public_html/youryardsales/inventory_images/'; $uploadfile = $uploaddir . basename($_FILES['file']['name']); if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) { echo "File is valid, and was successfully uploaded.\n"; } else { echo "Possible file upload attack!\n"; } //rest of the code. ?>
  6. One comment, Guys I never saw a comment on whether it is ok to have a picture field in this case name="file" and the rest of the text files together in one form. so in case I wanted to bring that up, I have done a update picture form submit alone with text fields with two form one for the picture field alone and then another for the text fields. I just want to know if it is ok to go ahead and work with one form or not.
  7. dind't quite understand so I have to get isset() around them ok. my bad
  8. The only undefined variables I had were the ones that were not defined such as $user_pic which I took that from another file code by mistake and $product that was mispelled now the real problem lay down in the indexes undefined indexes. I still on step 3 to 4
  9. @teynon From worked I checked the site was having some issues with the connection, @PFMaBiSmAd thank you.
  10. What happened with the rest of the replies? they erased them? The list of instructions given by PFMaBiSmAd and the other last suggestions. I just came home ready to work on that...
  11. I have put the error_reporting script on top and there is an undefined index according to error_reporting function. it comes out as undefined after it goes through a function. <?php function error_for($name){ global $errors; if($errors[$name]){ return "<div class='form_error'>". $errors[$name]; ?> This is the function which will print the errors below each field on the test for validations to see if the fields are empty or not. the undefined index will display on the screen below each form field before being submitted and after submittion with the error reporting_script above. Didn't see any error concerning the move_uploaded_file() function or the folder inventory_images. Don't know if those undefined indexes are the ones causing the problem, eventhough the INSERT query is inserting the field values in the database but the file in Mr, Inventory_images.
  12. I thought about the permissions, thought I think I have done that. Yes there is a folder called inventory_images in the same folder where the file is. This is the result for inventory_images folder Permission for this folder are set to 0755
  13. I finally came into an editor and figure out what was happening. Ok I have some result on the debugging script you just gave me. Yes the field $_FILES['file']['name'] Can't be move, Basically the form is submitted but the picture field not... The quote above is what is printing in the browser. In other words is not getting inside the folder. This is the script I am using to upload the file. <?php if (0 === count($errors)){ if (!$_FILES['file']['tmp_name']) { $error_msg = '<font color="#FF0000">ERROR: Please browse for an image before you press submit.</font>'; } else { $maxfilesize = 501200; // 51200 bytes equals 50kb if($_FILES['file']['size'] > $maxfilesize ) { $error_msg = '<font color="#FF0000">ERROR: Your image was too large, please try again.</font>'; unlink($_FILES['file']['tmp_name']); } else if (!preg_match("/\.(gif|jpg|png)$/i", $_FILES['file']['name'] ) ) { $error_msg = '<font color="#FF0000">ERROR: Your image was not one of the accepted formats, please try again.</font>'; unlink($_FILES['file']['tmp_name']); } else { $newname = $id . ".jpg"; // $place_file = move_uploaded_file( $_FILES['file']['tmp_name'], "inventory_images/$newname"); if(!move_uploaded_file( $_FILES['file']['tmp_name'], "inventory_images/$newname"){print "Cannot move {$_FILES['file']['name']}"; // Check to make sure the move result is true before continuing if ($place_file != true) { echo "ERROR: File not uploaded. Try again."; } } ?>[code] If there is not error the script above is set to upload or move_upload to the folder images_inventories. I am looking to name the picture or file to the user_id that's why I have tried to re-name it to [code]<?php $newname = $id . ".jpg" ?>
  14. i have placed this <?php if($place_file != true){ print("Cannot move {$_FILES['file']['name'])}"; $success_msg = '<font color="#009900">Your image has been updated, it may take a few minutes for the changes to show... please be patient.</font>';?> there is a parse error I don't have editor for blind people here lol I am a work Don't see a T_VARIABLE error here.
×
×
  • 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.