
09-14-2002, 02:06 PM
|
|
Junior Guru Wannabe
|
|
Join Date: Sep 2002
Location: Canada
Posts: 35
|
|
Uploading in Safe_Mode
I'm currently making a script and I wish to upload files but my server is in safe_mode and I cannot change that.
I want to know if it's possible to upload a file but instead of creating the file on the hard drive, I would store it inside a table in MySQL. If it is possible, where can I get some information or anything that would help me upload in safe_mode.
__________________
EZScripts - Quality PHP Scripts, Low Price (includes Custom Scripting on request.)
http://www.EZScripts.net/
Last edited by Chr1s; 09-14-2002 at 02:12 PM.
|

09-14-2002, 02:15 PM
|
|
Web Hosting Master
|
|
Join Date: May 2002
Location: UK
Posts: 2,994
|
|
I have no problem with this with safe mode enabled.
The code in this tutorial will work with safe mode enabled... i've used and adapted it myself.
http://www.phpbuilder.com/columns/florian19991014.php3
|

09-14-2002, 02:24 PM
|
|
Junior Guru Wannabe
|
|
Join Date: Sep 2002
Location: Canada
Posts: 35
|
|
Thanks for the fast reply and thanks a LOT for that link 
|

09-14-2002, 03:08 PM
|
|
Junior Guru Wannabe
|
|
Join Date: Sep 2002
Location: Canada
Posts: 35
|
|
The tutorial was made with php3 could someone help me convert this to php4?
PHP Code:
<?php
// store.php3 - by Florian Dittmer <dittmer@gmx.net>
// Example php script to demonstrate the storing of binary files into
// an sql database. More information can be found at [url]http://www.phpbuilder.com/[/url]
?>
<HTML>
<HEAD><TITLE>Store binary data into SQL Database</TITLE></HEAD>
<BODY>
<?php
// code that will be executed if the form has been submitted:
if ($submit) {
// connect to the database
// (you may have to adjust the hostname,username or password)
MYSQL_CONNECT("localhost","root","password");
mysql_select_db("binary_data");
$data = addslashes(fread(fopen($form_data, "r"), filesize($form_data)));
$result=MYSQL_QUERY("INSERT INTO binary_data (description,bin_data,filename,filesize,filetype) ".
"VALUES ('$form_description','$data','$form_data_name','$form_data_size','$form_data_type')");
$id= mysql_insert_id();
print "<p>This file has the following Database ID: <b>$id</b>";
MYSQL_CLOSE();
} else {
// else show the form to submit new data:
?>
<form method="post" action="<?php echo $PHP_SELF; ?>" enctype="multipart/form-data">
File Description:<br>
<input type="text" name="form_description" size="40">
<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="1000000">
<br>File to upload/store in database:<br>
<input type="file" name="form_data" size="40">
<p><input type="submit" name="submit" value="submit">
</form>
<?php
}
?>
</BODY>
</HTML>
|

09-14-2002, 03:51 PM
|
|
Newbie
|
|
Join Date: Aug 2002
Location: San Jose, California
Posts: 16
|
|
It looks to me like it would work in php4 also... But I don't really know... You can always just label it script.php3 but if you want to use only parts of it... Copy some code snipets out and trial/error with it...
__________________
-magz
|

09-14-2002, 07:38 PM
|
|
Web Hosting Master
|
|
Join Date: May 2002
Location: UK
Posts: 2,994
|
|
It will work in PHP 4 with globa variables turned on in the php.ini
To test this you can see it in the phpinfo(); function.
However if you can't run that because your server admin has disabled it then try posting a field called 'test' from a form to a php script. If you can echo the value to the screen as $test then global variables is enabled and the script will work without any changes.
|

09-15-2002, 11:56 AM
|
|
Junior Guru Wannabe
|
|
Join Date: Sep 2002
Location: Canada
Posts: 35
|
|
my server has it disabled..
lets say I wanted to do this:
$data = addslashes(fread(fopen($form_data, "r"), filesize($form_data)));
$result=MYSQL_QUERY("INSERT INTO binary_data (description,bin_data,filename,filesize,filetype) ".
"VALUES ('$form_description','$data','$form_data_name','$form_data_size','$form_data_type')");
i wont be able to do $form_data anymore cuz its empty... what do i do? $HTTP_POST_VARS['form_data'] ?
|

09-15-2002, 02:23 PM
|
|
Web Hosting Master
|
|
Join Date: May 2002
Location: UK
Posts: 2,994
|
|
No the preferred method is $_POST['form_data']
|

09-15-2002, 04:24 PM
|
|
Junior Guru Wannabe
|
|
Join Date: Sep 2002
Location: Canada
Posts: 35
|
|
so if I wanted to get the $form_data_size variable I'd use $_POST['form_data_size'] ? You sure about that?
__________________
EZScripts - Quality PHP Scripts, Low Price (includes Custom Scripting on request.)
http://www.EZScripts.net/
|

09-15-2002, 06:49 PM
|
|
Web Hosting Master
|
|
Join Date: May 2002
Location: UK
Posts: 2,994
|
|
Yes that is the php 4.1.x + method of using POST variables.
http://www.php.net/manual/en/languag...predefined.php
Quote:
|
$_POST: Variables provided to the script via HTTP POST. Analogous to the old $HTTP_POST_VARS array (which is still available, but deprecated).
|
|

09-15-2002, 09:50 PM
|
|
Junior Guru Wannabe
|
|
Join Date: Sep 2002
Location: Canada
Posts: 35
|
|
Alright, I figured it all out and modified lots of it. Thanks for the help.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
| Postbit Selector |
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
| Login: |
|
|
| Advertisement: |
|
|
| Web Hosting News: |
|
|
|