This topic is locked

Upload always same filename

9/22/2016 7:09:22 AM
PHPRunner General questions
G
gino author

Hi is there anyway to use the uplaod feature in PHPrunner to always force the file to be uploaded

romaldus 10/1/2016



Hi is there anyway to use the uplaod feature in PHPrunner to always force the file to be uploaded


It depends on:

  1. what file type you want to upload (picture file or documents file)
  2. Where you store the uploaded file, directly in database (blob file type) or in a directory in web server
    As a simple example, you want to upload the same picture when add new record in my_cool_table.

    In this scenario you need to create 2 tables, for example: table:
    ==============================================================

    [b][color="#0000ff"]Constant_picture


    id (integer, autonumber, primary key)

    picture (varchar 500)

    ==============================================================

    constant_picture table storing images to be used by my_cool_table

    In PHPRunner, configure the "picture" field to upload file/image to specific folder in web server.
    ==============================================================



    id (integer, autonumber, primary key)

    field1

    field2

    field3

    cool_picture (varchar 500)

    ==============================================================
    In [color="#ff0000"]my_cool_table [b]before record added event
    use the following code to copy JSON values from picture field from constant_picture table



$sql = "SELECT picture AS pict FROM constant_picture WHERE id = 'any_value_you_want'";

$rs = CustomQuery($sql);

$data = db_fetch_array($rs);

$_SESSION["default_picture"] = $data["pict"];
$values['cool_picture'] = $_SESSION["default_picture"];


Don't forget to configure the cool_picture field to show image (view as image)

Sergey Kornilov admin 10/1/2016

This option is a default in PHPRunner unless you use 'Basic upload' option.