hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : Uploading in Safe_Mode
Reply

Forum Jump

Uploading in Safe_Mode

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 09-14-2002, 02:06 PM
Chr1s Chr1s is offline
Junior Guru Wannabe
 
Join Date: Sep 2002
Location: Canada
Posts: 35
Question

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.


Sponsored Links
  #2  
Old 09-14-2002, 02:15 PM
Rich2k Rich2k is offline
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

  #3  
Old 09-14-2002, 02:24 PM
Chr1s Chr1s is offline
Junior Guru Wannabe
 
Join Date: Sep 2002
Location: Canada
Posts: 35
Talking

Thanks for the fast reply and thanks a LOT for that link

Sponsored Links
  #4  
Old 09-14-2002, 03:08 PM
Chr1s Chr1s is offline
Junior Guru Wannabe
 
Join Date: Sep 2002
Location: Canada
Posts: 35
Unhappy

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')");

    
$idmysql_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>

  #5  
Old 09-14-2002, 03:51 PM
mAgz mAgz is offline
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

  #6  
Old 09-14-2002, 07:38 PM
Rich2k Rich2k is offline
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.

  #7  
Old 09-15-2002, 11:56 AM
Chr1s Chr1s is offline
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'] ?

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

  #9  
Old 09-15-2002, 04:24 PM
Chr1s Chr1s is offline
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/

  #10  
Old 09-15-2002, 06:49 PM
Rich2k Rich2k is offline
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).

  #11  
Old 09-15-2002, 09:50 PM
Chr1s Chr1s is offline
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.

Reply

Related posts from TheWhir.com
Title Type Date Posted
The Growing Risks of Shadow IT within Organizations Web Hosting News 2014-02-21 09:55:49
Elastica Launches Data Science Powered Cloud Security Solution, Raises $6.3M in Funding Web Hosting News 2014-02-20 10:32:24
FireLayers Emerges from Stealth Mode with Policy-Based Security Platform for Cloud Apps Web Hosting News 2014-02-18 12:51:57
Inside 1&1's New Hosting Services and Approach Web Hosting News 2013-09-04 10:10:05
Web Host PeakColo Releases PaaS Based on Uhuru Software Technology Web Hosting News 2012-09-25 15:06:34


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?