Make a subdirectory called /gallery/thumbs/
That is where the thumbnail gets saved.
The filename will be the same as the fullsize, but in the /thumbs/ directory.

I added a function to make+save the thumbs, and set the size to 100 (you can change that).
I'm not the author of this function ... I just use it all the time because it works so good.
That resize function is a nice one to save in your "snippets" folder for use on other scripts.

Oh, and I use a shared webhost online ...
You're using your own server? Are the / the wrong way ? /\/\/\ ??

jarv

11-11-2011, 11:05 PM

no no, it works but only with certain .jpg files?!

tangoforce

11-11-2011, 11:24 PM

As suggested to you earlier, have you tried debugging yet?

jarv

11-12-2011, 12:13 AM

hmm, how to debug that though?!

MattF

11-12-2011, 12:26 AM

echo.

jarv

11-12-2011, 12:28 AM

yeah, echo what though?! it's a JPG file... surely it should upload?!

tangoforce

11-12-2011, 01:36 AM

yeah, echo what though?! it's a JPG file... surely it should upload?!

Without a doubt the file HAS uploaded - the browser will do that automatically. The problem happens with the move_uploaded_file() function. If you don't get your filepaths correct then as soon as the script terminates, the files are deleted from the temp directory automatically by php.

Jarv, if you want to be a programmer, you MUST learn to debug your code. This is one of the very fundamentals of programming in any language. You can't just find bits of code and put them together and then get everyone else to fix them (well you can but eventually you will get let down).

You must learn to debug. Your post above where you say "hmm, how to debug that though?!" is the first sign of progress and its a good one. In all the months you've been here you're finally asking how to debug and thats good - very good.

Firstly you need to do this somewhere in your code to determine what the $_FILES array contains (such as temp names etc):

var_dump($_FILES);

That should give you the basics of what you need to know. The rest is pretty much the same thing- printing out variables to be sure that they contain the correct values that you think they should. Thats basically all that debugging is - printing values to check things are as they should.

When it comes to files, sometimes you need to run additional code - using if(file_exists()) and if (is_dir()) etc and then print out your yes/no values accordingly. You do it like this:

That code came from YOUR code. THAT is how you debug but sometimes you have to debug every single line of code until you find the fault. Yes that can be hard work but it can save you the amount of time that you waste waiting for us to help you. You could fix it in an hour or two or wait 8-9 hours for us to help you. What is best?

You can also log things to a database for scripts that can't output anything and there are ways of doing that using var_export($Var, true); instead of var_dump().

I promise you jarv, once you've learnt the basics of debugging it gets a LOT easier :thumbsup: