PHP, Wordpress, Bluehost... Upload function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
corsair130
Forum Newbie
Posts: 2
Joined: Sun Jun 20, 2010 7:28 pm

PHP, Wordpress, Bluehost... Upload function

Post by corsair130 »

Background... I don't know PHP very well at all. I've watched a number of tutorials. I can do basic stuff. I am actively trying to learn just enough to get what I need to do done.

What I am trying to do, is add the upload file function to my wordpress blog. I would like for visitors of my blog to be able to upload a file to me, particularly video and picture files. My blog is hosted on bluehost. Bluehost had a one click install of the wordpress architecture.

Wordpress inherently uses php programming. I added a PHP code plugin that allows me to add PHP code to a widget. This is what I want. I just want to throw a upload button in a column on my blog.

And this is where it gets confusing to me. The code isn't that hard to understand for the upload function. What I'm having a hard time understanding is how to make it work.

Does anyone have any experience with wordpress, and bluehost, that can point me in the right direction? What I need to know how to do, is to make sure that bluehost's set up by default allows uploads in it's installment of PHP, and if not, how to go about changing that. Also, I need to understand where the file structures are by default so that I can make a new folder to copy the files to after the script runs. Where does this folder need to be? And what will the data path look like in the PHP script?


I hope all of this makes sense. I have a general understanding of what I need to accomplish, and a begginer's understanding of PHP, I just need some advice on how to put it all together and make it work on my wordpress blog that's hosted on Bluehost. Any help would be appreciated.
Phoenixheart
Forum Contributor
Posts: 123
Joined: Tue Nov 16, 2004 7:46 am
Contact:

Re: PHP, Wordpress, Bluehost... Upload function

Post by Phoenixheart »

First, for bluehost and file upload location: I'm pretty sure you are completely in control of your shared host account, which means you can upload the files to whatever directory you want, as long as it's under your root dir. WordPress itself has a directory dedicated for uploading at wp-content/uploads

Now, on to how to upload with WordPress. It may not sound so great to you, but as WP has its own mechanism of handling HTTP requests including uploads, so you may want to learn a bit about WP first. As far as I remember, WP even has its own upload functions which cover almost all of the hard part for us (can't recall the names now).
corsair130
Forum Newbie
Posts: 2
Joined: Sun Jun 20, 2010 7:28 pm

Re: PHP, Wordpress, Bluehost... Upload function

Post by corsair130 »

Phoenixheart wrote:First, for bluehost and file upload location: I'm pretty sure you are completely in control of your shared host account, which means you can upload the files to whatever directory you want, as long as it's under your root dir. WordPress itself has a directory dedicated for uploading at wp-content/uploads

Now, on to how to upload with WordPress. It may not sound so great to you, but as WP has its own mechanism of handling HTTP requests including uploads, so you may want to learn a bit about WP first. As far as I remember, WP even has its own upload functions which cover almost all of the hard part for us (can't recall the names now).
As far as I understand it, the uploading functions that are included with wordpress pertain to me uploading stuff to my own server to place in my blog. What I'm trying to do, is allow the general public to upload video files to a folder on my server.

I might be getting somewhere though... Like, I didn't understand exactly how and where apache and php are installed on bluehost's servers. One of the things that I know I needed to do was to change the default values for maximum file upload which are set at 2M. Since wordpress was "one click" installed for me, I didn't have a clue where the php.ini file was to change this.

I found a blog post that described how to change this on a wordpress blog. Basically, I had to add the php.ini file to the wp admin folder and change the default values before adding this. So there was NO php.ini file to control this already there. I added it. Now I believe that I'll be able to upload larger files. I haven't tested this yet though.


What I tried to do initially is to just copy and paste some generic upload function code. The code that I was copying and pasting pertained to picture files. When I did this, I got some weird error messages. There were no buttons for "browse and upload". If I took out the php, the buttons where there. Ok, whatever.

So what I think was possibly the problem was that there wasn't a default installation of php there. As I understand it, the php upload function will put your uploads in a temporary folder, then copy the file to another default folder called upload or something like this. And what I'm thinking is that because there was no real php.ini file in my installation, that there was no temporary folder in the first place, nor maybe even an upload folder. There definitely is an "upload" folder in my wordpress installation, but I don't know if php recognized that as where to put the files.

Basically, I'm still scratching my head as to how to get this done. Like I said, I now have a php.ini file installed in my admin folder of my wordpress installation, and I'm hoping that that file sets the rules for what I'm trying to do. And that with that file in place, the upload function will work by the default settings that it's supposed to.

Am I thinking about this right? Also, if any of you guys could post the code I need to do this, with a few pointers as to the things that I need to customize it myself it would be much appreciated. Like point out the string where I have to punch in the data path for the folder I want the files to be dropped into, as well as the string for the temp folder.
:banghead:


Note, I don't know php, but I have had at least some fun learning what I have learned so far.
Post Reply