php-general Digest 28 Mar 2011 11:18:30 -0000 Issue 7247
Topics (messages 312076 through 312086):
Permission Denied
312076 by: Ethan Rosenberg
312078 by: Hans Ã
hlin
is there any syntax to save a file in mysql?
312077 by: Negin Nickparsa
312079 by: Hans Ã
hlin
312080 by: Ashley Sheridan
312081 by: Negin Nickparsa
312082 by: Negin Nickparsa
312083 by: Geoff Lane
312084 by: Negin Nickparsa
312085 by: Ashley Sheridan
312086 by: Bastien
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
Dear List -
Thanks for all your help in the past. Here is another one...
I am getting a Permission Denied" message when I try to run a PHP
script. I just changed the mode on the directory and the files to
777. This problem arose when I changed the permissions. I thought I
was solving a problem, because I could not open a file for
writing. I was not receiving error messages, but no file was created.
Help and advice, please.
Ethan Rosenberg
--- End Message ---
--- Begin Message ---
Do you have SELinux installed?
2011/3/28 Ethan Rosenberg <[email protected]>:
> Dear List -
>
> Thanks for all your help in the past. Here is another one...
>
> I am getting a Permission Denied" message when I try to run a PHP script. I
> just changed the mode on the directory and the files to 777. This problem
> arose when I changed the permissions. I thought I was solving a problem,
> because I could not open a file for writing. I was not receiving error
> messages, but no file was created.
>
> Help and advice, please.
>
> Ethan Rosenberg
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
**********************************************
Hans Åhlin
Tel: +46761488019
icq: 275232967
http://www.kronan-net.com/
irc://irc.freenode.net:6667 - TheCoin
**********************************************
--- End Message ---
--- Begin Message ---
in php i have a file to upload i want to save this file in a table and then
retreive it from table in another situation is it possible?
--- End Message ---
--- Begin Message ---
2011/3/28 Negin Nickparsa <[email protected]>:
> in php i have a file to upload i want to save this file in a table and then
> retreive it from table in another situation is it possible?
>
I assume you are thinking of saving it in a MySQL table?
If so read this http://dev.mysql.com/doc/refman/5.0/en/blob.html
--
**********************************************
Hans Åhlin
Tel: +46761488019
icq: 275232967
http://www.kronan-net.com/
irc://irc.freenode.net:6667 - TheCoin
**********************************************
--- End Message ---
--- Begin Message ---
On Mon, 2011-03-28 at 07:36 +0200, Hans Åhlin wrote:
> 2011/3/28 Negin Nickparsa <[email protected]>:
> > in php i have a file to upload i want to save this file in a table and then
> > retreive it from table in another situation is it possible?
> >
> I assume you are thinking of saving it in a MySQL table?
> If so read this http://dev.mysql.com/doc/refman/5.0/en/blob.html
>
>
> --
>
>
> **********************************************
> Hans Åhlin
> Tel: +46761488019
> icq: 275232967
> http://www.kronan-net.com/
> irc://irc.freenode.net:6667 - TheCoin
> **********************************************
>
Personally, I'd save the file as a file but use the DB to remember
details about it. For example, what I tend to do is save the file under
the name it gets given in the temp directory, and in the DB store its
original name, the temp name it's stored under, extension & any other
info I might find useful (such as the user who uploaded it if this is a
user-based system like a CMS)
--
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
---------- Forwarded message ----------
From: Negin Nickparsa <[email protected]>
Date: Mon, Mar 28, 2011 at 10:24 AM
Subject: Re: [PHP] is there any syntax to save a file in mysql?
To: Hans Åhlin <[email protected]>
tnx Hans
now i run this code
in my sql ihave this:
CREATE TABLE upload (
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(30) NOT NULL,
type VARCHAR(30) NOT NULL,
size INT NOT NULL,
*content MEDIUMBLOB NOT NULL,*
PRIMARY KEY(id)
);
and in my notepad i have this:
<?php
if(isset($_POST['upload']) && *$_FILES['userfile']['size'] > 0*)
{
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
*$content = addslashes($content);*
fclose($fp);
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
}
include 'connect.php';
$query = "INSERT INTO upload (name, size, type, content ) ".
"VALUES ('$fileName', '$fileSize', '$fileType', '$content')";
mysql_query($query) or die('Error, query failed');
include 'library/closedb.php';
echo "<br>File $fileName uploaded<br>";
}
?>
<form method="post" *enctype="multipart/form-data"*>
<table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
<tr>
<td width="246">
*<input type="hidden" name="MAX_FILE_SIZE" value="2000000">
<input name="userfile" type="file" id="userfile">*
</td>
<td width="80"><input name="upload" type="submit" class="box" id="upload"
value=" Upload "></td>
</tr>
</table>
</form>
but in my sql when i select * it goes on a bad loop with writing line like
this---------
-----------------------------------------------------------------------
--- End Message ---
--- Begin Message ---
---------- Forwarded message ----------
From: Negin Nickparsa <[email protected]>
Date: Mon, Mar 28, 2011 at 10:57 AM
Subject: Re: [PHP] is there any syntax to save a file in mysql?
To: [email protected]
Dear Ashley,but i want every user to have his/her own files in their
account. (i used session for them) n now i want them to have their specific
files then i think i must have db that store the files n user can retrieve
his/hers not just details
if i just save the details then how they download the files that they
receive from another users?
--- End Message ---
--- Begin Message ---
On Monday, March 28, 2011, Negin Nickparsa wrote:
> ... i want every user to have his/her own files in their account. (i
> used session for them) n now i want them to have their specific
> files then i think i must have db that store the files n user can
> retrieve his/hers not just details if i just save the details then
> how they download the files that they receive from another users?
One way is to create a directory for each user in which you store than
user's files. You can name each directory for the user's ID.
That strategy lets more than one user have the same filename, although
it doesn't let one user have more than one file with the same name
(which might be required for a CMS etc.)
Others can download files by clicking on hyperlinks to the target
files.
HTH,
--
Geoff
--- End Message ---
--- Begin Message ---
i want each user having more than one file like us in the inbox of our mails
i want to store files n then they can access each one.
--- End Message ---
--- Begin Message ---
"Negin Nickparsa" <[email protected]> wrote:
>i want each user having more than one file like us in the inbox of our
>mails
>i want to store files n then they can access each one.
Then do what I suggested and store the file under the temporary name its given
when it gets uploaded to the temp directory. Use the db to make a link between
that and the given real filename. Then you can store other info in the db such
as who uploaded it, who has permissions to view it, etc
Thanks
Ash
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
--- End Message ---
--- Begin Message ---
On 2011-03-28, at 3:37 AM, Negin Nickparsa <[email protected]> wrote:
> i want each user having more than one file like us in the inbox of our mails
> i want to store files n then they can access each one.
It's certainly possible, but as others have said, use the db to store the list
of files and use the filesystem to store the actual files in a folder for each
user.
From
Practical experience, after about 12gigabytes of data in the db, you will start
seeing performance issues. Not to mention time and performance issues when
backing the db.
Bastien Koert
Sent from my iPhone
--- End Message ---