Hi!
Can someone add a function that is checking if picture witdh is bigger then 800px whwn uploading, then echo "image oversized" to the code below?
Code: <?php
###/ VARIABLES - CHANGE ACCORDINGLY
define("VAR_BASE_DIRECTORY","/home/web30217/domains/mysite.com/public_html/");
define("VAR_UPLOAD_FOLDER","upload/");
define("VAR_UPLOAD_DIRECTORY",VAR_BASE_DIRECTORY.VAR_UPLOAD_FOLDER);
define("VAR_UPLOAD_FIELDS",1);
define("VAR_FILENAME_KEEP",0);
##/ Function that displays forms and is called by default
function defaultForm()
{
echo "<form method="post" enctype="multipart/form-data">n";
for($i=0; $i < VAR_UPLOAD_FIELDS; $i++)
{
echo "<input name="file[]" type="file" id="file[]" /><br />n";
echo "<div style="height:2px"></div>";
}
echo "<div style="height:1px"></div>";
echo "<br /><input name="Submit" type="image" src="/images/upload.jpg" value="Ladda upp">n";
echo "<input name="filter" type="hidden" value="processForm">n";
echo "</form>n";
return;
}
#/ End of defaultForm
##/ Function that displays forms and is called by default
function processForm()
{
for($i=0; $i < VAR_UPLOAD_FIELDS; $i++)
{
echo "";
if(!empty($_FILES[file][size][$i]))
{
if(VAR_FILENAME_KEEP==1)
{
##/ File maintaining upload name
$fileName = $_FILES[file][name][$i];
}
else
{
##/ Filename randomized
$fileName = rand(10000,400000).rand(1,10).'.' . substr($_FILES[file][name][$i], -3);
}
##/ Creating reference address
$newLocation = VAR_UPLOAD_DIRECTORY.$fileName;
if(!copy($_FILES[file][tmp_name][$i],$newLocation))
{
echo "<b>Failed - ".$_FILES[file][name][$i]." would not copy to ".$newLocation."</b> (Check your upload directory and permissions)";
}
else
{
###/ SUCCESS /###
#/ Stripping of VAR_BASE_DIRECTORY for better viewing and linking
$urlShow = str_replace(VAR_BASE_DIRECTORY,'',$newLocation);
echo "&#91;img&#93;http://mysite.com/$urlShow&#91;&#47;img&#93;";
}
}
else
{
echo "";
}
echo "<br />";
}
return;
}
#/ End of processForm
##/ This object handles which function the application should call
switch($_POST[filter]) {
case "processForm":
processForm();
break;
default:
defaultForm();
break;
}
#/ End of Handling
?>
New to Arrays
Hi I am new to PHP (a week and a half now) and I am just beginning to read about arrays. I understand simple arrays, associative arrays, and multidimensional arrays also. The book I am reading
Sendmail.php - heading error following check_input
Hi,I would greatly appreciate some help? I am brand new to PHP and have been searching and editing code ALL day :shrug:yet I still cannot find the reason for this error in my Sendmail.php
am I using this for loop correctly
Dear buddies!
Convert .fdf to .pdf
I currently have a web form that uploads the form data to an .fdf file and emails it.However, I just realized that most people I email it to cannot open an .fdf and it needs to be in pdf.Is there any
Help with PHP and checkboxes
I am posting this for a friend of mine, i wrote a small script for her to process her form data to an email but in testing i am having trouble getting the checkbox data to display in the email it
Writting a script to arrange images........ need some help
Ok so here is the linkhttp://hmtotc.com/dev/projects/vrassociates/jeweler_dev/admin/index.php?id=arrange&loc=4I am wondering if there is a way to have the text field hold a hidden value so I
Expandable Post Code
Hi,Hope you can help. Which currently I haven't upgraded to connect to a mysql server, so its all just plain html and php coding. I have a page that displays short news articles of about 25 30 words
filesize() returns 0
I have a socket program that runs in an infinite loop, listening for connections, in this socket I have a method, that is supposed to open a file and write to the file, but I am having issues. Each
Progress bar for webpage
Hi,I want to implement a progress/waiting bar on my webpage - exactly the same thing that the Microsoft Update web page uses when your PC is being searched for available updates (the green bar that
Drawing Images in classes
I'm quite new to Object Oriented PHP. What I'm trying to do is draw some images but also have other content on the page.Code: include('images.php');//New Image set$im=new images();//Sends headers and