473,782 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP unable to Upload to Fileserver

7 New Member
Is there any one who could help with a problem. I have an application that uploads images to a file server with my upload directory set thus:[PHP]define('ALBUM_I MG_DIR', 'C:/Inetpub/wwwroot/sites/supportbridges/www/admin/profile/images/album/');[/PHP]

This is how it is on my local computer running on IIS, now I want to transfer the same application to a Linux host. What can I do to shorten the directory link so as to be able to upload images to the same folder: The upload folder is "album"
Dec 5 '06 #1
5 2626
underground
41 New Member
Is there any one who could help with a problem. I have an application that uploads images to a file server with my upload directory set thus:[PHP]define('ALBUM_I MG_DIR', 'C:/Inetpub/wwwroot/sites/supportbridges/www/admin/profile/images/album/');[/PHP]

This is how it is on my local computer running on IIS, now I want to transfer the same application to a Linux host. What can I do to shorten the directory link so as to be able to upload images to the same folder: The upload folder is "album"
How funny this I used this example toturial last week. Any how you need to change from c:/inetpub to something more like /home/www.domain/

for the script to work. You must reflect the relitive path on the sever not your local computer.
Dec 5 '06 #2
Objectifnet
7 New Member
Thanks for your help, I have set the relative part but it displays a blank page.

My relative path is: /var/www/html/domains/supportbridges. org/documentroot/sbi/images/album/

Please is there any suggestion why it keeps displaying a blank page instead of displayin the uploaded images.
Dec 6 '06 #3
underground
41 New Member
It would be a big help if You showed the code because I can only guess...
Dec 6 '06 #4
Objectifnet
7 New Member
Ok Thanks, here are the codes:
The code below is my code for config. It defines the upload directory and also the database connection:

[PHP]<?php
# FileName="Conne ction_php_mysql .htm"
# Type="MYSQL"
# HTTP="true"
$hostname_connx = "localhost" ;
$database_connx = "sbdb";
$username_connx = "root";
$password_connx = "sbdbadm1n" ;
$connx = mysql_pconnect( $hostname_connx , $username_connx , $password_connx ) or trigger_error(m ysql_error(),E_ USER_ERROR);

// an album can have an image used as thumbnail
// we save the album image here
define("ALBUM_I MG_DIR", "/var/www/html/domains/supportbridges. org/documentroot/sbi/images/album/
");

// all images inside an album are stored here
define("GALLERY _IMG_DIR", "/var/www/html/domains/supportbridges. org/documentroot/sbi/images/gallery/"); ;

// When we upload an image the thumbnail is created on the fly
// here we set the thumbnail width in pixel. The height will
// be adjusted proportionally
define('THUMBNA IL_WIDTH', 40);

// make a connection to mysql here
$connx = mysql_connect ($hostname_conn x, $username_connx , $password_connx ) or die ("I cannot connect to the database because: " . mysql_error());
mysql_select_db ($database_conn x) or die ("I cannot select the database '$dbname' because: " . mysql_error());
?>[/PHP]

Now here is my functions code the handles the thumbnail creation and other stuff.

[PHP]<?php
# FileName="Conne ction_php_mysql .htm"
# Type="MYSQL"
# HTTP="true"
$hostname_connx = "localhost" ;
$database_connx = "sbdb";
$username_connx = "root";
$password_connx = "sbdbadm1n" ;
$connx = mysql_pconnect( $hostname_connx , $username_connx , $password_connx ) or trigger_error(m ysql_error(),E_ USER_ERROR);

// an album can have an image used as thumbnail
// we save the album image here
define("ALBUM_I MG_DIR", "/Inetpub/wwwroot/projects/support/images/album/");

// all images inside an album are stored here
define("GALLERY _IMG_DIR", "/Inetpub/wwwroot/projects/support/images/gallery/"); ;

// When we upload an image the thumbnail is created on the fly
// here we set the thumbnail width in pixel. The height will
// be adjusted proportionally
define('THUMBNA IL_WIDTH', 40);

// make a connection to mysql here
$connx = mysql_connect ($hostname_conn x, $username_connx , $password_connx ) or die ("I cannot connect to the database because: " . mysql_error());
mysql_select_db ($database_conn x) or die ("I cannot select the database '$dbname' because: " . mysql_error());
?>[/PHP]

Now here is my add album code the adds new album to the fileserver and database.

[PHP]<?php
require_once '../library/config.php';
require_once '../library/functions.php';
if(isset($_POST['txtName']))
{
$albumName = $_POST['txtName'];
$albumDesc = $_POST['mtxDesc'];

$imgName = $_FILES['fleImage']['name'];
$tmpName = $_FILES['fleImage']['tmp_name'];

// we need to rename the image name just to avoid
// duplicate file names
// first get the file extension
$ext = strrchr($imgNam e, ".");

// then create a new random name
$newName = md5(rand() * time()) . $ext;

// the album image will be saved here
$imgPath = ALBUM_IMG_DIR . $newName;

// resize all album image
$result = createThumbnail ($tmpName, $imgPath, THUMBNAIL_WIDTH );

if (!$result) {
echo "Error uploading file";
exit;
}

if (!get_magic_quo tes_gpc()) {
$albumName = addslashes($alb umName);
$albumDesc = addslashes($alb umDesc);
}

$query = "INSERT INTO tbl_album (al_name, al_description, al_image, al_date)
VALUES ('$albumName', '$albumDesc', '$newName', NOW())";

mysql_query($qu ery) or die('Error, add album failed : ' . mysql_error());

// the album is saved, go to the album list
echo "<script>window .location.href= 'index.php?page =list-album';</script>";
exit;
}
?>

<form action="" method="post" enctype="multip art/form-data" name="frmAlbum" id="frmAlbum">
<table width="100%" border="0" cellpadding="2" cellspacing="1" class="table_gr ey">
<tr>
<th width="150">Alb um Name</th>
<td width="80" bgcolor="#FFFFF F"> <input name="txtName" type="text" id="txtName"></td>
</tr>
<tr>
<th width="150">Des cription</th>
<td bgcolor="#FFFFF F"> <textarea name="mtxDesc" cols="50" rows="4" id="mtxDesc"></textarea>
</td>
</tr>
<tr>
<th width="150">Ima ge</th>
<td bgcolor="#FFFFF F"> <input name="fleImage" type="file" class="box" id="fleImage"> </td>
</tr>
<tr>
<td width="150" bgcolor="#FFFFF F">&nbsp;</td>
<td bgcolor="#FFFFF F"> <input name="btnAdd" type="submit" id="btnAdd" value="Add Album">
<input name="btnCancel " type="button" id="btnCancel" value="Cancel" onClick="window .history.back() ;"></td>
</tr>
</table>
</form>
[/PHP]

Now here is the page it ought to link to, the list-album page.

[PHP]<?php
$albumPerPage = 10;

$pageNumber = isset($_GET['pageNum']) ? $_GET['pageNum'] : 1;

$offset = ($pageNumber - 1) * $albumPerPage;
$serial = $offset + 1;

$sql = "SELECT al_id, al_name, al_image, COUNT(im_album_ id) AS al_numimage
FROM tbl_album al LEFT JOIN tbl_image im ON al.al_id = im.im_album_id
GROUP by al_id
ORDER BY al_name ";
$result = mysql_query($sq l . "LIMIT $offset, $albumPerPage") or die('Error, list album failed. ' . mysql_error());

?>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="table_gr ey">
<tr>
<th width="30" align="center"> #</th>
<th align="center"> Album Name</th>
<th width="120" align="center"> Images</th>
<th width="60" align="center"> &nbsp;</th>
<th width="60" align="center"> &nbsp;</th>
</tr>
<?php
if (mysql_num_rows ($result) == 0) {
?>
<tr bgcolor="#FFFFF F">
<td colspan="5">No album yet</td>
</tr>
<?php
} else {
$serial = $offset + 1;
while ($row = mysql_fetch_ass oc($result)) {
extract($row);

$al_numimage = "<a href=\"?page=li st-image&album=$al _id\">$al_numim age</a>";
?>
<tr bgcolor="#FFFFF F">
<td width="30" align="center"> <?php echo $serial++; ?></td>
<td align="center"> <a href="?page=alb um-detail&alId=<?p hp echo $al_id; ?>"><img src="../viewImage.php?t ype=album&name= <?php echo $row['al_image']; ?>" border="0" /><br />
</a><a href="?page=alb um-detail&amp;alId =<?php echo $al_id; ?>"><?php echo $al_name; ?></a></td>
<td width="120" align="center"> <?php echo $al_numimage; ?></td>
<td width="60" align="center"> <a href="?page=mod ify-album&alId=<?ph p echo $al_id; ?>">Modify</a></td>
<td width="60" align="center"> <a href="javascrip t:deleteAlbum(< ?php echo $al_id; ?>);">Delete</a></td>
</tr>
<?php
} // end while
}
?>
<tr bgcolor="#FFFFF F">
<td colspan="5" align="center"> <?php
$result = mysql_query($sq l);
$totalResults = mysql_num_rows( $result);

echo getPagingLink($ totalResults, $pageNumber, $albumPerPage, "page=list-album");
?>&nbsp;</td>
</tr>
<tr bgcolor="#FFFFF F">
<td colspan="5" align="right">< input type="button" name="btnAdd" value="Add Album" onclick="window .location.href= 'index.php?page =add-album';" /></td>
</tr>
</table>

[/PHP]

Please help, thanks.
Dec 7 '06 #5
seangates
19 New Member
// resize all album image
$result = createThumbnail ($tmpName, $imgPath, THUMBNAIL_WIDTH );
I couldn't find the createThumbnail function anywhere. Is there more code than what you posted?

Sean
Dec 8 '06 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
1563
by: Marco Aschwanden | last post by:
Hi I would like to install Python on a fileserver. All the machines (all Win2K) should afterwards use this Python installation. The (Python) apps I am developing will be as well placed on the fileserver. My advantages would be: - I have to keep only 1 Python installation up-to-date. - (Frequent) changes of the apps are easily distributed by copying them to the fileserver.
1
6118
by: Hrvoje Vrbanc | last post by:
Hello all, I have a web server in a domain and would like to upload files using an ASP.NET application that resides on the aforementioned server but the destination folder for upload is a shared folder that is located on a different server within a trusted domain. I have tried everything I could come up with: I mapped the shared folder as the "Z:" drive on the web server, I used UNC name and IP address as the possible paths in the...
1
308
by: Adam aku | last post by:
Hi! I suppose this is an easy problem but despite searching through manuals I have not as yet been able to solve it I have a asp .net web form which needs to access files from our fileserver. The problem is that the IIS and web app are on a different server than the fileserver (both are win2003 servers) The IIS settings are set to windows authentication, my app has impersonation and windows authentication, yet still I receive an error when...
0
981
by: foozhiqin | last post by:
Hi All, I have a program to for user to upload file into server with the form appliation. Can anyone advise me if i should save the file into FileServer or save into SQL database as byte Array. Pro and Con.
0
789
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted by the software in your host machine. Stack Trace at System.Net.Sockets.NetworkStream.Write(Byte buffer, Int32 offset, Int32
3
14056
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted by the software in your host machine. Stack Trace at System.Net.Sockets.NetworkStream.Write(Byte buffer, Int32 offset, Int32
9
3900
by: Steve Poe | last post by:
I work for an animal hospital trying to use PHP to store an animal's dental x-rays to a file server. I can browse for the xray on the local desktop computer then click "Upload Image". This works fine. The doctors want fewer steps to follow. So, it was asked if I can configure the browser to load/submit the image 'xray.tif' each time they click "Upload Image" instead of the doctor/animal technician having to look for for dental x-ray...
0
2674
by: ll | last post by:
I'm working with 'pure ASP upload' script which is designed to redirect to an alert/error message, should a file larger than the set limit be attempted to be uploaded. The problem is that, while smaller files do upload successfully, the script does not catch the larger files and rather than a specific error message in Firefox (and IE7), I just get the following: ------------------------------------ The connection was reset The...
5
6814
by: kailashchandra | last post by:
I am trying to upload a file in php,but it gives me error msg please Help me? My Code is like below:- i have one php file named upload.php and i have another html file named upload.html and inside html i am calling php file upload.php:- <?php
0
9641
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10146
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9944
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.