Uploading file architecture
Posted: Mon Jun 07, 2010 9:00 pm
Hi, I'm new here.
Basically, I am now designing some web forms for my company using PHP and MS SQL.
I am now at this point whereby I need to create a upload form..
Not sure if this topic is rightfully to be here or to be in theory and design forum.. nevertheless, please assist if any of you knows
My current handling is convert the uploaded file:
I am aware that move_uploaded_file — Moves an uploaded file to a new location from PHP context. but not sure if my above codes are logical or wasting time?
I am saving to my DB as Hex, 0x30783733363433343631363436643064306132343434333434313336366432343633363130643061306430613064306133393337333733303337333933313337
And now trying to figure out to download as stream, which realized I'm doing extra work.
My workaround now, using the same method, move_upload_files, my logic design will moved the upload file to the file server which involved folder permission. So in my DB, I will store the file path rather than the raw data itself. And when I hit download button, the web form will download the file from the file server with permission to (Execute only).
But I read some articles that move_upload_files did was move the files to a temp dir, and once done, the file will be gone.. is this true and is my methodology above workable?
and in my php.ini,
;upload_tmp_dir = I have to set the upload folder here. But do I still need to specify in my script?
Basically, I am now designing some web forms for my company using PHP and MS SQL.
I am now at this point whereby I need to create a upload form..
Not sure if this topic is rightfully to be here or to be in theory and design forum.. nevertheless, please assist if any of you knows
My current handling is convert the uploaded file:
Code: Select all
if ($_FILES["fSHORT_FILE"]["error"] > 0){
echo "Return Code: " . $_FILES["fSHORT_FILE"]["error"] . "<br />";
fileerror="x";
}else if(file_exists("upload/".$_FILES["fSHORT_FILE"]["name"])){
echo $_FILES["fSHORT_FILE"]["name"] . " already exists. ";
fileerror="x";
}else{
$tmpFileName="";
move_uploaded_file($_FILES["fSHORT_FILE"]["tmp_name"],"upload/" . $_FILES["fSHORT_FILE"]["name"]);
$tmpFileName = $_FILES['fSHORT_FILE']['tmp_name'];
$dataString = file_get_contents($tmpFileName);
$arrData = unpack("H*hex", $dataString);
$sSHORT_FILE = "0x".$arrData['hex'];
}I am saving to my DB as Hex, 0x30783733363433343631363436643064306132343434333434313336366432343633363130643061306430613064306133393337333733303337333933313337
And now trying to figure out to download as stream, which realized I'm doing extra work.
My workaround now, using the same method, move_upload_files, my logic design will moved the upload file to the file server which involved folder permission. So in my DB, I will store the file path rather than the raw data itself. And when I hit download button, the web form will download the file from the file server with permission to (Execute only).
But I read some articles that move_upload_files did was move the files to a temp dir, and once done, the file will be gone.. is this true and is my methodology above workable?
and in my php.ini,
;upload_tmp_dir = I have to set the upload folder here. But do I still need to specify in my script?