Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

php image upload help

Options
  • 24-06-2008 4:42pm
    #1
    Registered Users Posts: 8,070 ✭✭✭


    My flash file basically contacts this php file

    [PHP]<?php
    if ($_FILES) {
    move_uploaded_file($_FILES, '../img/' . basename($_FILES));
    }
    ?>[/PHP]

    [which apparently places it on the server where the actual file resides on]

    So to upload to an SQL server im assuming i need to convert it into bytes etc?

    considering i have a blob field.

    will this work


    [PHP]//connect to db

    $fileContent = getImageFile($_FILES);
    $uploadedImage = chunk_split(base64_encode($fileContent));

    $query = "INSERT INTO images_table VALUES('NULL','$uploadedImage')";
    [/PHP]

    thanks


    [BTW im going to be storing some details in an XML file for each user, and so later on il need to load these details/picture, so would it work out easier if i just store image on server and store path+user id etc etc]
    Tagged:


Comments

  • Closed Accounts Posts: 94 ✭✭Done and dusted


    I would personally store the image files directly to the server and then store a refrence link to it in the db. My rational behind this is based on the extra overhead in the conversion process via the code.

    Also What happens if the db has a file limit on. I know the hosting package I have has a size limit on my db's.


  • Registered Users Posts: 8,070 ✭✭✭Placebo


    yeah basically i have database for register and login and upon login they can design their character and that preference will be stored in an XML, which will then be loaded upon reading a specific id created during reg,

    so i suppose straight to server will probably be a more feasible solution, security wise, the folder will have to have public write permissions, so any workarounds?

    thanks


  • Closed Accounts Posts: 94 ✭✭Done and dusted


    on the security front....mmm......

    Well what you could do is have the code that handles the storage of images (server side) work under a user account that is the only one to have write access to the folder dir. So essentially you would create an account and give it write access to the folder and then have your server side code use that account to do all of the storage stuff.


Advertisement