I make modifications for Invision's software and I never can figure out how to do any kind of upload script using their attachment system.
Someone told me I could use a "simple php script". I learned php on my own and with online peopel's help so I am not sure where to start with this particular thing.
All I want to do is simple... Make a browse button to browse your PC, upload ONE image. That's it. No ened for a fancy flash upload system, no need for multiple attachments, probably no need to resize it or limit size at this point.
I could use this on SEVERAL scripts. It's holding me back by not being able to do it.
Upload Script?
Started by BASHERS33, Aug 28 2009 05:04 PM
8 replies to this topic
#1
Posted 28 August 2009 - 05:04 PM
|
|
|
#2
Posted 28 August 2009 - 05:09 PM
#3
Guest_Jordan_*
Posted 28 August 2009 - 05:11 PM
Guest_Jordan_*
There are tutorials on here as well:
http://forum.codecal...load-class.html
http://forum.codecal...ing-system.html
Even one of my tutorials teaches you how to upload to a database (with images):
http://forum.codecal...-mysql-php.html
http://forum.codecal...load-class.html
http://forum.codecal...ing-system.html
Even one of my tutorials teaches you how to upload to a database (with images):
http://forum.codecal...-mysql-php.html
#4
Posted 28 August 2009 - 06:01 PM
Thanks so much, both of you. Looks simple. I will play around with it. I wish i knew what Invision's software would do automatically for me where I dont have to use $_FILES. For example I enver have to use $_GET or $_POST since Invision already sends things from the form through various things folr security and formatting and it ends up being $this->request[$value]. I wish I knew if $_FILES type of data is already cleaned/secured somewhere.
Is there anything to do not shown in ofne of these examples for secutiry purposes? I assume since the file types allowed will be pic file types it's not dangerous anyway?
Is there anything to do not shown in ofne of these examples for secutiry purposes? I assume since the file types allowed will be pic file types it's not dangerous anyway?
#5
Posted 29 August 2009 - 09:10 PM
How can i remove an uploaded file? i don't see a way to do it with the move function.
I'm not asking how to let it overwrite a file with the same name, as that's obvious... you do nothing if you want that to happen. I want to know how I can specify a file and have it removed from the directory where someone can't upload the one picture and then keep changing their pic and it have a lot of space wasted on pics when only 1 is used.
Also oddly when I started the upload path with Website Hosting - Mysite.com it returned false for is_dir and is_writable. yet if I did it as "uploads/" without any url in it then it worked properly.
I'm not asking how to let it overwrite a file with the same name, as that's obvious... you do nothing if you want that to happen. I want to know how I can specify a file and have it removed from the directory where someone can't upload the one picture and then keep changing their pic and it have a lot of space wasted on pics when only 1 is used.
Also oddly when I started the upload path with Website Hosting - Mysite.com it returned false for is_dir and is_writable. yet if I did it as "uploads/" without any url in it then it worked properly.
#6
Posted 29 August 2009 - 09:15 PM
Files are automatically put into the tmp folder which gets taken out regularly, but if you move it yourself, then unlink should do the trick
PHP: unlink - Manual
PHP: unlink - Manual
#7
Posted 29 August 2009 - 09:34 PM
Thanks. Also I think if I use if( $_FILES ) in my check it always passes even if someone didn't upload anyting. Is that becasue $_FILES would still be an empty array if they didn't use the browse button to upload a file and left it blank?
#8
Posted 29 August 2009 - 09:50 PM
Nevermind. I used print_r to see that it's indeed an empty array.
I need to change how I am doing it regardless, but still nice to know.
edit: nice. I got everything working. some thigns I learned from one of those links and some things from another of them. so nice combo of links you guys gave. I spent proobably 3-4 hours on it because I had to tweak things and do some extra stuff for what I needed it for. I made it where when editing something that already has a pic uploaded it shows the pic on the edit form and if you check the checkbox that says delete it then has a hidden div show up with the upload box to upload a new image and unlink() is then used to delete the old one if you checked that box and it will upload the new one. if you leave it blank but check the box it will delete and not upload anything. otherwise deletes and adds the new one.
Then soem tricky things where I had to return FALSE, return TRUE, or return ana ctual array depending on various things. lol
I'm not a programmer "as a real job" so I think it's fun and cool when I get something working. lol
I need to change how I am doing it regardless, but still nice to know.
edit: nice. I got everything working. some thigns I learned from one of those links and some things from another of them. so nice combo of links you guys gave. I spent proobably 3-4 hours on it because I had to tweak things and do some extra stuff for what I needed it for. I made it where when editing something that already has a pic uploaded it shows the pic on the edit form and if you check the checkbox that says delete it then has a hidden div show up with the upload box to upload a new image and unlink() is then used to delete the old one if you checked that box and it will upload the new one. if you leave it blank but check the box it will delete and not upload anything. otherwise deletes and adds the new one.
Then soem tricky things where I had to return FALSE, return TRUE, or return ana ctual array depending on various things. lol
I'm not a programmer "as a real job" so I think it's fun and cool when I get something working. lol
Edited by BASHERS33, 30 August 2009 - 01:33 AM.
#9
Posted 30 August 2009 - 07:36 AM
Well I am glad you got it working. If you need anymore help don't be scared to ask!


Sign In
Create Account


Back to top










